ffmpeg: isolate one audio channel

6,677

You have two methods:

pan audio filter

The pan audio filter is powerful but the syntax takes some time to understand.

It is helpful to refer to the channel layouts list when using pan: ffmpeg -layouts

Stereo right channel to mono:

ffmpeg -i stereo.wav -af "pan=mono|FC=FR" right_mono.wav

...which is the same as:

ffmpeg -i stereo.wav -af "pan=1|c0=c1" right_mono.wav
  • mono is output channel layout or number of channels. Alternatively you could use 1 instead of mono.
  • FC=FR create the Front Center channel of the output from the Front Right of the input.
  • c0=c1 is the same as the above in this case: create the first (and only) channel of the mono output (c0) from the second channel (c1) of the input.
  • If you want the left channel instead use FC=FL or c0=c0.

More info:


-map_channel

You can use the -map_channel option. It uses pan in the background and is somewhat less flexible.

ffmpeg -i stereo.wav -map_channel 0.0.1 right_mono.wav
  • The first 0 is the input file ID
  • The next 0 is the stream specifier
  • The 1 is the channel ID

So this can be translated as: first file, first stream, second channel (or right channel).

From the -map_channel documentation:

The order of the -map_channel option specifies the order of the channels in the output stream. The output channel layout is guessed from the number of channels mapped (mono if one -map_channel, stereo if two, etc.

Share:
6,677

Related videos on Youtube

stephenwade
Author by

stephenwade

Updated on September 18, 2022

Comments

  • stephenwade
    stephenwade over 1 year

    How can I use ffmpeg to isolate one channel from an audio file? I have a stereo audio file, and I need the output to be the contents of the right channel in a mono audio file.

    While I'm sure it's fairly easy to do, I can't figure it out. Thanks for the help!

  • Louis Waweru
    Louis Waweru almost 11 years
    Interstingly, on FLAC/WAV files -map_channel is nearly instantaneous saying "Pure channel mapping detected".
  • Elisa Cha Cha
    Elisa Cha Cha almost 11 years
    @Louis See Remapping examples for an explanation of "Pure channel mapping detected".
  • Louis Waweru
    Louis Waweru almost 11 years
    Ah nice, so pan seems superior in that it can do pure channel mapping on lossy files too.
  • Bernhard Bodenstorfer
    Bernhard Bodenstorfer almost 4 years
    I guess a shell command line would need some quotation around pan=mono|FC=FR or pan=1|c0=c1 in order not to misinterpret the piping character |, wouldn't it?
  • Elisa Cha Cha
    Elisa Cha Cha almost 4 years
    @BernhardBodenstorfer Yes, it's recommended. I updated the answer. Looks like I was being lazy when I later added the pan section and didn't test it.