Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 8 down vote accepted

You have two methods:

-map_channel

You can use the -map_channel option:

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.

pan audio filter

You could also use the pan audio filter:

ffmpeg -i stereo.wav -af pan=1:c0=c1 right_mono.wav
  • 1 is output channel layout or number of channels
  • c0=c1 is the "outdef", or output channel specification
  • c0 represents the desired output channel number
  • c1 represents the input channel to use

Make sure to read the pan documentation first.

share|improve this answer
    
Interstingly, on FLAC/WAV files -map_channel is nearly instantaneous saying "Pure channel mapping detected". – Louis May 31 '13 at 18:36
1  
@Louis See Remapping examples for an explanation of "Pure channel mapping detected". – LordNeckbeard May 31 '13 at 18:46
    
Ah nice, so pan seems superior in that it can do pure channel mapping on lossy files too. – Louis May 31 '13 at 18:53
    
@Louis I think it should be the same. The console output of the -map_channel example shows, -map_channel is forwarded to lavfi similarly to -af pan=0x4:c0=c1, and the md5 muxer shows that the streams are the same. I don't quite understand 0x4 though. – LordNeckbeard May 31 '13 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .