How to Upmix Stereo to 5.1 in FFmpeg Using Pan

This guide explains how to use the FFmpeg pan audio filter to upmix a stereo (2.0) audio track into a 5.1 surround sound channel layout. You will learn the command syntax, the channel mapping configurations, and how to apply custom weight coefficients to distribute the left and right stereo inputs across the six target surround sound channels.

Understanding the 5.1 Channel Layout

A standard 5.1 surround sound layout consists of six distinct channels. When mapping channels in FFmpeg, they are identified by the following labels:

In a stereo input file, the audio channels are represented as c0 (Left channel) and c1 (Right channel).

The Pan Filter Syntax

The pan filter configuration requires you to specify the output channel layout followed by the specific mix equations for each output channel. The basic structure is:

pan=layout|output_channel=equation|output_channel=equation|...

For a 5.1 output, you start with pan=5.1. You then define how c0 (Left) and c1 (Right) map to the six output channels using multiplication factors (weights) ranging generally from 0.0 to 1.0.

Custom Weights Configuration

To create a realistic surround sound experience from a stereo source, you can distribute the audio using these custom weights:

The FFmpeg Command

To apply these custom weights, run the following FFmpeg command in your terminal:

ffmpeg -i input.wav -af "pan=5.1|FL=c0|FR=c1|FC=0.7*c0+0.7*c1|LFE=0.5*c0+0.5*c1|BL=0.7*c0|BR=0.7*c1" output.wav

Key Considerations for Adjusting Weights