0

from ffmpeg man page, I should be able to use -map_channel to split/mute channels however, unless the stream contain 2 channels literately, the map does not work.

01.mp3:

Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s

ffmpeg -threads 1 -i 01.mp3 -map_channel 0.0.1 -map_channel -1 01R.mp3 is not going to work:

Stream #0:0 -> #0:0 [ch: 1 M] (mp3 -> libmp3lame)

however, the 01R.mp3 will still be a stereo stream which contain both L and R channels.

If I convert the mp3 into wav, then it became a double channel stream:

ffmpeg -threads 1 -i 01L.mp3 01LR.wav
    Stream mapping:
      Stream #0:0 -> #0:0 (mp3 -> pcm_s16le)
ffprobe 01LR.wav
Input #0, wav, from '01LR.wav':
  Duration: 00:40:20.42, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s

I can mute/split the wav file.

How can I mute/split the stereo stream without convert it to 2-channel wav file first?

Thanks

[Edit] according to @LordNeckbeard:

$ ffmpeg -threads 1 -i 01.mp3 -map_channel 0.0.1 -map_channel -1 01R.mp3
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 26 2014 09:49:36 with gcc 4.6.3
  configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
[mp3 @ 0x115f6e0] max_analyze_duration 5000000 reached at 5015510
Input #0, mp3, from '01.mp3':
  Metadata:
    title           : VTS_01_1
    author          : BT
    copyright       : Happy@2006
    comment         : 
    encoder         : Lavf53.32.100
  Duration: 00:40:20.42, start: 0.000000, bitrate: 128 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s
Output #0, mp3, to '01R.mp3':
  Metadata:
    TIT2            : VTS_01_1
    author          : BT
    TCOP            : Happy@2006
    comment         : 
    TSSE            : Lavf53.32.100
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 [ch: 1 M] (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
Truncating packet of size 1024 to 189ate= 128.0kbits/s    
Truncating packet of size 1024 to 1
size=   37820kB time=00:40:20.45 bitrate= 128.0kbits/s    
video:0kB audio:37820kB global headers:0kB muxing overhead 0.001381%

[Edit2]:

as I described above ffmpeg -i 01.mp3 -map_channel 0.0.1 01R.wav or ffmpeg -i 01.wav -map_channel 0.0.1 01R.mp3 will work. But ffmpeg -i 01.mp3 -map_channel 0.0.1 01R.mp3 does not work.

I found a way to do mono channel mp3 by adding -ac 1: ffmpeg -i 01.mp3 -ac 1 -map_channel 0.0.1 01R.mp3

However, use -map_channel -1 to mute one channel in stereo output stream still does not work.

3
  • Please show the complete ffmpeg console output from your first command.
    – llogan
    Nov 13, 2014 at 5:45
  • Thanks for the console output, but I'm confused about what you want to do. Do you want to mute a channel and result in a stereo output, or do you just want one of the channels and result in a mono output?
    – llogan
    Nov 13, 2014 at 19:07
  • either way will do: mute a channel in stereo or extract one channel to form mono output.
    – Wang
    Nov 14, 2014 at 5:25

1 Answer 1

0

Mute a channel

mute a channel

This example takes a stereo input and mutes the left channel. The output remains stereo:

ffmpeg -i stereo.wav -map_channel -1 -map_channel 0.0.1 output.wav

Stereo channel to mono

Stereo channel to mono output

This example creates a mono output from the left channel of the stereo input:

ffmpeg -i stereo.mp3 -map_channel 0.0.0 left.wav
  • Use -map_channel 0.0.1 if you want the right channel instead.

Or you could use the pan audio filter:

ffmpeg -i stereo.m4a -af "pan=1:c0=c0" left.flac
  • Use pan=1:c0=c1 if you want the right channel instead.
3
  • what is the difference between your answer and the commands I used in my post? the -map_channel does not work as expected with stereo stream. It will only work when it is a 2-channel stream. The -af does not get supported till much later release.
    – Wang
    Nov 16, 2014 at 1:18
  • can you try the -map_channel with a stereo stream and output as mp3? It won't work, As I said I knew I can convert to to wav then to mp3, but I want to eliminate the intermediary step.
    – Wang
    Nov 16, 2014 at 1:26
  • @Wang Use a recent ffmpeg. I can't provide support for old branches.
    – llogan
    Nov 16, 2014 at 3:54

You must log in to answer this question.

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