Switch channels of stereo sound

Problem

Switch the front left (FL) and front right (FR) channels of a stereo sound.

Solution

ffmpeg \
    -i input_file \
    -map_channel 0.a.1 \
    -map_channel 0.a.0 \
    output_file

Command syntax

ffmpeg
starts the command
-i input_file
path, name and extension of the input file
-map_channel 0.a.1
grabs the right channel of the stereo sound
-map_channel 0.a.0
grabs the left channel of the stereo sound
output_file
path, name and extension of the output file

Discussion

The sound channels are mapped in the inverted order, therefore they are written in the inverted order into the output file. As usual in IT, the numbering starts at 0, not at 1 (“zero-based numbering”).

Check with ffprobe the streams’ mapping to ensure the code is accurate.


2020-07-15