Record PulseAudio Monitor Audio with FFmpeg
Capturing desktop or application audio on Linux requires routing sound through a PulseAudio "monitor" source, which mirrors your system's output as an input stream. This guide demonstrates how to locate your active PulseAudio monitor device using terminal utilities and execute the appropriate FFmpeg command to record system audio directly to a file without capturing external microphone noise.
Step 1: Identify the PulseAudio Monitor Source
PulseAudio creates a virtual monitor device for every physical audio output. To list all available sources and identify your monitor device, open a terminal and run:
pactl list short sources | grep monitorThe output will display the active sources. Look for an entry ending
in .monitor corresponding to your active sound card or
sink. For example:
1 alsa_output.pci-0000_00_1f.3.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz RUNNING
The string in the second column (e.g.,
alsa_output.pci-0000_00_1f.3.analog-stereo.monitor) is the
device name you will provide to FFmpeg.
Alternatively, if you want to capture whichever device is currently set as your default output, you can typically use:
default.monitor
Step 2: Record the Audio Using FFmpeg
Once you have the monitor name, use FFmpeg's pulse input
format to capture the audio stream.
Record to Lossless WAV
To record uncompressed system audio:
ffmpeg -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor output.wavRecord to MP3
To compress the audio using the MP3 format with a specific bitrate:
ffmpeg -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -c:a libmp3lame -b:a 192k output.mp3Record Using the Default Monitor
If you prefer not to hardcode the hardware device name:
ffmpeg -f pulse -i default.monitor -c:a flac output.flacStep 3: Stop the Recording
To end the capture session cleanly, press Ctrl + C in
the terminal window running the FFmpeg command. FFmpeg will flush the
buffer and finalize the audio container file.