YouTube screen capture with audio using FFmpeg

1 minute read

Related: YouTube Live streaming with 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:

python -m pip install youtubeliveffmpeg
from youtubelive_ffmpeg import disksave4youtube

P = {'fps': 30,
     'res': '1920x1080',
     'origin': (0,0),
     'audiochan': 'default',


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 \

audio config

-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


video config explained

-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.

Compile FFmpeg

Most Linux distros have old FFmpeg versions. You can compile your own current stable FFmpeg by

git clone

apt install autoconf automake build-essential libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev libfdk-aac-dev libx264-dev yasm libmp3lame-dev libopus-dev libvpx-dev libx265-dev

./configure --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libpulse

make -j4

make install


Leave a Comment