YouTube screen capture with audio using FFmpeg

YouTube screen capture with audio is simple, cross-platform and stable using nothing more than FFmpeg.

Get the easy-to-use Python script for YouTube FFmpeg screen capture with audio: ScreenCapture2disk.py.

pip install pylivestream

ScreenCapture2disk my.avi

The following details are not normally needed–just use the easy Python script above. YouTube screen capture with audio:

ffmpeg \
-video_size 1024x720 \
-framerate 10 \
-f x11grab -i :0.0+100,200 \
-f pulse -ac 2 -i default \
-c:a libmp3lame -ar 48000 \
out.mkv

The audio config is handled by:

-f pulse -ac 2 -i default
send stereo audio with the default PulseAudio device.

DO NOT USE -ac 1 even with monaural audio as you’ll get lots of errors like

non-monotonous DTS in output stream 0:1;

-c:a libmp3lame -ar 44100
encode audio as MP3 with a 44.1 kHz sampling frequency (passing audio up to about 22 kHz, which is CD-quality).

List PulseAudio devices:

pactl list sources

Control audio sources with:

pavucontrol

Video config -framerate 10 -f x11grab -i :0.0+0,0 screengrab at 10 fps, starting in the upper left hand corner, send a 1024x720 pixel video. If your screen resolution is more than 1024x720, there would be unsent regions at the bottom and/or right side.


Related: YouTube Live streaming with FFmpeg