You can also try using βwaitβ to automate the execution and stop of a program. You will need to start it using some virtual shell, for example screen
, tmux
or byobu
, and then run ffmpeg
inside it. Thus, you can again get the virtual shell screen and provide the "q" parameter.
Run a virtual shell session locally or remotely, say, using a βscreenβ. Name the session the -S
option, for example screen -S recvideo
Then you can run ffmpeg as you like. You can optionally disconnect from this session with Ctrl + a + d.
Connect to the machine where ffmpeg is running inside the screen (or tmux or something else) and connect to it: screen -d -RR recvideo
, and then send "q"
To do this from within the script, you can use expect, for example:
prompt="> " expect << EOF set timeout 20 spawn screen -S recvideo expect "$prompt" send -- "ffmpeg xxxxx\r" set timeout 1 expect eof EOF
Then at another point, either at the script point or in another script, you will restore it:
expect << EOF set timeout 30 spawn screen -d -RR recvideo expect "$prompt" send -- "q" expect "$prompt" send -- "exit\r" expect eof EOF
You can also automate an entire waiting ssh
session by passing a sequence of commands and βwaitingβ to do what you want.
source share