10 Provide a shell used to send interactive commands to a zmq filter.
12 The command assumes there is a running zmq or azmq filter acting as a
15 You can send a command to it, following the syntax:
16 TARGET COMMAND [COMMAND_ARGS]
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
22 See the zmq/azmq filters documentation for more details, and the
23 zeromq documentation at:
27 logging
.basicConfig(format
='zmqshell|%(levelname)s> %(message)s', level
=logging
.INFO
)
28 log
= logging
.getLogger()
31 class LavfiCmd(cmd
.Cmd
):
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
)
40 def onecmd(self
, cmd
):
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}")
50 argparse
.ArgumentDefaultsHelpFormatter
, argparse
.RawDescriptionHelpFormatter
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')
59 args
= parser
.parse_args()
61 LavfiCmd(args
.bind_address
).cmdloop('FFmpeg libavfilter interactive shell')
62 except KeyboardInterrupt:
66 if __name__
== '__main__':