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.
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,
superfastuses more efficient compression than
superfastif your computer allows.