How to Downmix 7.1 to 5.1 Audio with FFmpeg
This article provides a quick guide on how to downmix a 7.1 surround sound audio track to a 5.1 channel layout using FFmpeg. You will learn the exact command-line syntax to perform this conversion efficiently while preserving audio quality and copying the video stream without re-encoding.
The Basic Downmix Command
The simplest and most common way to downmix audio in FFmpeg is by
using the -ac (audio channels) option. Setting this to
6 tells FFmpeg to output 5.1 audio (which consists of 6
channels: Front Left, Front Right, Center, LFE, Surround Left, and
Surround Right).
Run the following command in your terminal:
ffmpeg -i input.mkv -c:v copy -c:a aac -ac 6 output.mkvCommand Breakdown: * -i input.mkv:
Specifies your input video file containing the 7.1 audio. *
-c:v copy: Copies the video stream directly without
re-encoding it, saving time and preserving original video quality. *
-c:a aac: Encodes the output audio to the AAC format (you
can change this to ac3, eac3, or
flac depending on your needs). * -ac 6:
Downmixes the 8 channels of the 7.1 audio into the 6 channels of 5.1
audio. * output.mkv: The name of your output file.
Advanced Downmix Using the Pan Filter
If you want precise control over how the 7.1 channels (which include
side and back speakers) are mapped and mixed into the 5.1 channels, you
can use FFmpeg’s pan audio filter. This prevents volume
loss and ensures the back channels are correctly merged into the
surround channels.
Run the following command:
ffmpeg -i input.mkv -c:v copy -af "pan=5.1|FL=FL|FR=FR|FC=FC|LFE=LFE|SL=0.5*SL+0.5*BL|SR=0.5*SR+0.5*BR" -c:a aac output.mkvHow the Pan Filter Works here: * FL=FL
/ FR=FR / FC=FC / LFE=LFE: Keeps
the Front Left, Front Right, Center, and Subwoofer channels exactly as
they are. * SL=0.5*SL+0.5*BL: Mixes 50% of the Side Left
(SL) and 50% of the Back Left (BL) channels into the final Surround Left
channel. * SR=0.5*SR+0.5*BR: Mixes 50% of the Side Right
(SR) and 50% of the Back Right (BR) channels into the final Surround
Right channel.