hwcontext_vulkan: fix VkImageToMemoryCopyEXT.sType
[ffmpeg.git] / tools / zmqshell.py
1 #!/usr/bin/env python3
2
3 import argparse
4 import cmd
5 import logging
6 import sys
7 import zmq
8
9 HELP = '''
10 Provide a shell used to send interactive commands to a zmq filter.
11
12 The command assumes there is a running zmq or azmq filter acting as a
13 ZMQ server.
14
15 You can send a command to it, following the syntax:
16 TARGET COMMAND [COMMAND_ARGS]
17
18 * TARGET is the target filter identifier to send the command to
19 * COMMAND is the name of the command sent to the filter
20 * COMMAND_ARGS is the optional specification of command arguments
21
22 See the zmq/azmq filters documentation for more details, and the
23 zeromq documentation at:
24 https://zeromq.org/
25 '''
26
27 logging.basicConfig(format='zmqshell|%(levelname)s> %(message)s', level=logging.INFO)
28 log = logging.getLogger()
29
30
31 class LavfiCmd(cmd.Cmd):
32 prompt = 'lavfi> '
33
34 def __init__(self, bind_address):
35 context = zmq.Context()
36 self.requester = context.socket(zmq.REQ)
37 self.requester.connect(bind_address)
38 cmd.Cmd.__init__(self)
39
40 def onecmd(self, cmd):
41 if cmd == 'EOF':
42 sys.exit(0)
43 log.info(f"Sending command: {cmd}")
44 self.requester.send_string(cmd)
45 response = self.requester.recv_string()
46 log.info(f"Received response: {response}")
47
48
49 class Formatter(
50 argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
51 ):
52 pass
53
54
55 def main():
56 parser = argparse.ArgumentParser(description=HELP, formatter_class=Formatter)
57 parser.add_argument('--bind-address', '-b', default='tcp://localhost:5555', help='specify bind address used to communicate with ZMQ')
58
59 args = parser.parse_args()
60 try:
61 LavfiCmd(args.bind_address).cmdloop('FFmpeg libavfilter interactive shell')
62 except KeyboardInterrupt:
63 pass
64
65
66 if __name__ == '__main__':
67 main()