Desktop Capture with FFMPEG
From the FFMPEG WIKI it is simple:
ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4
Recording audio with ffmpeg did not work well when I tried (see the references)
but recording using arecord
works very well in general.
To record audio with arecord
, first find the correct capture device:
arecord --list-pcm
Then, choose the correct one from the list and add it as the --device
argument:
arecord --device=sysdefault:CARD=Microphone --channels=1 -f cd > output.wav
The recorded audio will be written to output.wav
. The problem at this
point is recording from the same starting point so that they can be muxed
later.
To start two commands at the same time (and be able to capture output) I used
tmux
with split panes... you could use windows but I though this was easier.
If you do not know about tmux you should find out it is a very useful tool.
This set of commands will create a new tmux session called work
, split it
and start some commands as if you typed them into the default shell prompt!
SESSION=work
tmux new-session -d -s $SESSION
# By default each window has one pane (pane 0) and at this stage
# window 0 exists which will be split into two vertically
tmux split-window -v -t $SESSION:0.0
# Now we have $SESSION:0.0 and $SESSION:0.1 which we can send
# bytes to be read by our default shell
tmux send-keys -t $SESSION:0.0 'mpv output.mp4' Enter && \
tmux send-keys -t $SESSION:0.1 'mpv output.wav' Enter
How to stop two commands at the same time? Well simple, send Control-c
:
tmux send-keys -t $SESSION:0.0 C-c && \
tmux send-keys -t $SESSION:0.1 C-c