Skip to content

Instantly share code, notes, and snippets.

@genevera
Created December 28, 2023 03:58
Show Gist options
  • Select an option

  • Save genevera/ea9330873f5a9855cc81153d37a9e67f to your computer and use it in GitHub Desktop.

Select an option

Save genevera/ea9330873f5a9855cc81153d37a9e67f to your computer and use it in GitHub Desktop.

Revisions

  1. genevera created this gist Dec 28, 2023.
    35 changes: 35 additions & 0 deletions zmqshell3.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env python3

    ###############################################################################
    # you'll need to install pyzmq via `pip install pyzmq`
    ###############################################################################

    import cmd
    import sys

    import zmq


    class LavfiCmd(cmd.Cmd):
    prompt = "lavfi> "

    def __init__(self, bind_address):
    context = zmq.Context()
    self.requester = context.socket(zmq.REQ)
    self.requester.connect(bind_address)
    cmd.Cmd.__init__(self)

    def onecmd(self, cmd):
    if cmd == "EOF":
    sys.exit(0)
    print(f"Sending command: {cmd}")
    self.requester.send_string(cmd)
    message = self.requester.recv()
    print(f"Received reply: {message}")


    try:
    bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:5555"
    LavfiCmd(bind_address).cmdloop("FFmpeg libavfilter interactive shell")
    except KeyboardInterrupt:
    pass