zmqshell.py 725 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python2
  2. import sys, zmq, cmd
  3. class LavfiCmd(cmd.Cmd):
  4. prompt = 'lavfi> '
  5. def __init__(self, bind_address):
  6. context = zmq.Context()
  7. self.requester = context.socket(zmq.REQ)
  8. self.requester.connect(bind_address)
  9. cmd.Cmd.__init__(self)
  10. def onecmd(self, cmd):
  11. if cmd == 'EOF':
  12. sys.exit(0)
  13. print 'Sending command:[%s]' % cmd
  14. self.requester.send(cmd)
  15. message = self.requester.recv()
  16. print 'Received reply:[%s]' % message
  17. try:
  18. bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:5555"
  19. LavfiCmd(bind_address).cmdloop('FFmpeg libavfilter interactive shell')
  20. except KeyboardInterrupt:
  21. pass