How to Swap Left and Right Audio Channels with FFmpeg

This article provides a quick and practical guide on how to swap the left and right audio channels of a stereo file using the FFmpeg command-line tool. Whether you are working with an audio-only file like an MP3 or a video file like an MP4, you will learn the precise commands required to remap your stereo channels instantly.

Swapping Channels in an Audio File

To swap the left and right channels of a stereo audio file (such as MP3, WAV, or FLAC), you use the FFmpeg audio filter (-af) with the pan directive.

Run the following command in your terminal:

ffmpeg -i input.mp3 -af "pan=stereo|c0=c1|c1=c0" output.mp3

How this command works: * -i input.mp3: Specifies the input file. * -af: Applies an audio filter. * pan=stereo: Sets the output audio layout to stereo. * c0=c1: Maps the output’s left channel (channel 0) to the input’s right channel (channel 1). * c1=c0: Maps the output’s right channel (channel 1) to the input’s left channel (channel 0). * output.mp3: The name of your new audio file with swapped channels.

Swapping Channels in a Video File

If you are working with a video file, you want to swap the audio channels without re-encoding the video stream. Re-encoding video takes a long time and reduces quality. To avoid this, copy the video stream directly while processing only the audio.

Run the following command:

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

How this command works: * -c:v copy: Copies the video stream exactly as it is without re-encoding, saving time and preserving original video quality. * -af "pan=stereo|c0=c1|c1=c0": Swaps the left and right audio channels. * output.mp4: The output video file with the corrected audio channels.