Swap Audio Channels with FFmpeg Pan Filter

This article provides a quick, practical guide on how to swap the left and right audio channels in a stereo file using FFmpeg's powerful pan audio filter. You will learn the exact command-line syntax required to redirect your audio streams and see a concrete example of how to apply this filter without re-encoding your video.

To swap the left and right channels of a stereo audio track, you use the pan audio filter (-af) to map the input channels to different output channels.

The Swap Command

In a standard stereo configuration, channel 0 (c0) is the left channel and channel 1 (c1) is the right channel. To swap them, you tell FFmpeg to output a stereo stream where the new left channel takes the old right channel, and the new right channel takes the old left channel.

Run the following command in your terminal:

ffmpeg -i input.mp4 -af "pan=stereo|c0=c1|c1=c0" -c:v copy output.mp4

How It Works

  • -i input.mp4: Specifies your input video or audio file.
  • -af "pan=stereo|c0=c1|c1=c0": Applies the audio filter.
    • pan=stereo: Defines the output layout as stereo (two channels).
    • c0=c1: Maps output channel 0 (Left) to input channel 1 (Right).
    • c1=c0: Maps output channel 1 (Right) to input channel 0 (Left).
  • -c:v copy: Copies the video stream directly without re-encoding it, which saves time and preserves the original video quality.
  • output.mp4: The name of your new file with the swapped audio channels.