Created
December 28, 2023 03:58
-
-
Save genevera/ea9330873f5a9855cc81153d37a9e67f to your computer and use it in GitHub Desktop.
FFMPEG's zmqshell.py except it works with python3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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