How to Downmix 5.1 to Stereo with FFmpeg
Converting multi-channel 5.1 surround sound audio into a standard two-channel stereo track is a common task when preparing media for devices like phones, TVs, or headphones that do not support surround sound. This guide provides a straightforward, step-by-step tutorial on how to use FFmpeg, a powerful command-line tool, to quickly downmix 5.1 audio to stereo while preserving audio quality and channel balance.
Method 1: The Quick Automatic Downmix
The easiest way to downmix 5.1 audio to stereo is by using the
-ac 2 (audio channels) parameter. FFmpeg will automatically
handle the mixing of the six channels (Front Left, Front Right, Center,
LFE/Subwoofer, Surround Left, and Surround Right) into two channels.
Use the following command if you want to keep the original video and only downmix the audio:
ffmpeg -i input.mp4 -c:v copy -ac 2 output.mp4-i input.mp4: Specifies the input video file.-c:v copy: Copies the video stream directly without re-encoding, saving time and preserving video quality.-ac 2: Forces the output audio to have exactly 2 channels (stereo).output.mp4: The name of the new output file.
For an audio-only file (like WAV or FLAC), use this command:
ffmpeg -i input.wav -ac 2 output.wavMethod 2: Custom Downmix Using the Pan Filter (Recommended)
The automatic downmix method sometimes results in quiet dialogue or muddy bass because the center channel (which contains most of the speech) and the subwoofer channel are mixed directly with the side channels.
To prevent clipping (audio distortion) and maintain clear vocals, you
can use the pan audio filter to control exactly how much
volume each original channel contributes to the final stereo
channels.
Run this command to downmix using a standard, balanced matrix:
ffmpeg -i input.mp4 -c:v copy -af "pan=stereo|FL=0.5*FC+0.707*FL+0.707*BL|FR=0.5*FC+0.707*FR+0.707*BR" output.mp4Here is how the audio filter (-af) formula works: *
FL (Front Left output) receives 70.7% of the original Front
Left (FL), 70.7% of the Back Left (BL), and
50% of the Front Center (FC) channel. * FR
(Front Right output) receives 70.7% of the original Front Right
(FR), 70.7% of the Back Right (BR), and 50% of
the Front Center (FC) channel. * The Low-Frequency Effects
(LFE/Subwoofer) channel is omitted in this formula to prevent low-end
distortion on standard stereo speakers.
Method 3: Dolby Pro Logic II Downmix
If you plan to play your stereo track on a receiver that can decode surround sound from a stereo signal, you can downmix using the Dolby Pro Logic II compatible matrix. This embeds surround sound information directly into the stereo channels.
Run the following command:
ffmpeg -i input.mp4 -c:v copy -af "aresample=matrix_encoding=dplii" output.mp4