Skip to content

Instantly share code, notes, and snippets.

@genevera
Created December 28, 2023 03:58
Show Gist options
  • Save genevera/ea9330873f5a9855cc81153d37a9e67f to your computer and use it in GitHub Desktop.
Save genevera/ea9330873f5a9855cc81153d37a9e67f to your computer and use it in GitHub Desktop.
FFMPEG's zmqshell.py except it works with python3
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment