Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
774d358e
Commit
774d358e
authored
Mar 26, 2023
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/zmqshell: port to python3
Also extend docs, use argparse and logging.
parent
686e14e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
11 deletions
+52
-11
zmqshell.py
tools/zmqshell.py
+52
-11
No files found.
tools/zmqshell.py
View file @
774d358e
#!/usr/bin/env python2
#!/usr/bin/env python3
import
argparse
import
cmd
import
logging
import
sys
import
zmq
HELP
=
'''
Provide a shell used to send interactive commands to a zmq filter.
The command assumes there is a running zmq or azmq filter acting as a
ZMQ server.
You can send a command to it, follwing the syntax:
TARGET COMMAND [COMMAND_ARGS]
* TARGET is the target filter identifier to send the command to
* COMMAND is the name of the command sent to the filter
* COMMAND_ARGS is the optional specification of command arguments
See the zmq/azmq filters documentation for more details, and the
zeromq documentation at:
https://zeromq.org/
'''
logging
.
basicConfig
(
format
=
'zmqshell|
%(levelname)
s>
%(message)
s'
,
level
=
logging
.
INFO
)
log
=
logging
.
getLogger
()
import
sys
,
zmq
,
cmd
class
LavfiCmd
(
cmd
.
Cmd
):
prompt
=
'lavfi> '
...
...
@@ -14,13 +40,28 @@ class LavfiCmd(cmd.Cmd):
def
onecmd
(
self
,
cmd
):
if
cmd
==
'EOF'
:
sys
.
exit
(
0
)
print
'Sending command:[
%
s]'
%
cmd
self
.
requester
.
send
(
cmd
)
message
=
self
.
requester
.
recv
()
print
'Received reply:[
%
s]'
%
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
:
log
.
info
(
f
"Sending command: {cmd}"
)
self
.
requester
.
send
_string
(
cmd
)
response
=
self
.
requester
.
recv_string
()
log
.
info
(
f
"Received response: {response}"
)
class
Formatter
(
argparse
.
ArgumentDefaultsHelpFormatter
,
argparse
.
RawDescriptionHelpFormatter
)
:
pass
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
HELP
,
formatter_class
=
Formatter
)
parser
.
add_argument
(
'--bind-address'
,
'-b'
,
default
=
'tcp://localhost:5555'
,
help
=
'specify bind address used to communicate with ZMQ'
)
args
=
parser
.
parse_args
()
try
:
LavfiCmd
(
args
.
bind_address
)
.
cmdloop
(
'FFmpeg libavfilter interactive shell'
)
except
KeyboardInterrupt
:
pass
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment