Skip to content

Recording screen with FFmpeg


I'm not wanting to go into too much detail at the moment, but I have recently had the need for recording my screen for screencasts. I am using linux, with X11 (on i3wm) and my audio going through pulseaudio.

I have relied on resources such as the awesome Arch Wiki FFmpeg page and the FFmpeg Pulse Audio docs (to get the correct sound source selected).

The command I needed to run to record my screen was:

ffmpeg -f x11grab -video_size 1920x1080 -framerate 25 -i $DISPLAY -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -c:v libx264 -preset superfast -c:a aac screen.mp4

The important bits in this command that may need to change dependent on your setup are:

  • -f pulse - Telling ffmpeg we are using pulseaudio as the source.
  • -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor - Selecting the corect audio channel (which I got from running pactl list short sources).
  • -preset superfast - According to the Arch Wiki, superfast uses more efficient compression than ultrafast. Use superfast if your computer allows.