Ffmpeg Audio Stereo to Mono using only left channel

11

3

I use the following command to extract video parts of an '.MTS' record (video).

ffmpeg -i 00402.MTS -s 1280x720 -r 25 -ss 0:00:05.38608 -vcodec libxvid -qscale:v 2 -acodec ac3 -ar 48000 -ab 256k -t 0:00:06.613917 m001_mono.avi

The audio stream is stereo but the right channel only recorded noise. Here are the input informations:

Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1440x1080 [PAR 4:3 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, stereo, s16, 256 kb/s

I would like the output's audio stream to be mono (with the original left channel only). I already made tests using '-ac 1' option, but in this case the two channels are merged and I lose ~6dB of gain.

What option should I use to discard right channel and output with mono audio stream ?

EDIT: ffmpeg output with map_channel option

/home/eric/buildsys/ffmpeg-2.0.1/ffmpeg -i 00402.MTS -s 1280x720 -r 25 -ss 0:00:05.38608    -vcodec libxvid -qscale:v 2 -acodec ac3 -ar 48000 -ab 256k -t 0:00:06.61391 -map_channel -1 -map_channel 0.1.0 m001_test.avi
ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
 built on Sep 24 2013 05:31:18 with gcc 4.8 (Debian 4.8.1-10)
configuration: --extra-cflags=-I../static/include --extra-ldflags='-L../static/lib -static' --enable-gpl --enable-version3 --enable-static --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --disable-ffserver
libavutil      52. 38.100 / 52. 38.100
libavcodec     55. 18.102 / 55. 18.102
libavformat    55. 12.100 / 55. 12.100
libavdevice    55.  3.100 / 55.  3.100
libavfilter     3. 79.101 /  3. 79.101
libswscale      2.  3.100 /  2.  3.100
libswresample   0. 17.102 /  0. 17.102
libpostproc    52.  3.100 / 52.  3.100
Input #0, mpegts, from '00402.MTS':
Duration: 00:01:18.25, start: 0.455556, bitrate: 12217 kb/s
Program 1 
Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
File 'm001_test.avi' already exists. Overwrite ? [y/N] y
-map_channel is forwarded to lavfi similarly to -af pan=0x3:c1=c0.
[pan @ 0x248a560] This syntax is deprecated. Use '|' to separate the list items.
[pan @ 0x248a560] Pure channel mapping detected: M 0
Output #0, avi, to 'm001_test.avi':
Metadata:
ISFT            : Lavf55.12.100
Stream #0:0: Video: mpeg4 (libxvid) (xvid / 0x64697678), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 256 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libxvid)
Stream #0:1 -> #0:1 (ac3 -> ac3)
Press [q] to stop, [?] for help
frame=  166 fps= 23 q=2.0 Lsize=    4012kB time=00:00:06.64 bitrate=4950.3kbits/s    
video:3787kB audio:207kB subtitle:0 global headers:0kB muxing overhead 0.464949%

Eric

Posted 2014-01-16T13:32:09.870

Reputation: 201

Answers

9

You can modify a video file directly without having to re-encode the video stream. However the audio stream will have to be re-encoded.

Left channel to mono:

ffmpeg -i video.mp4 -map_channel 0.1.0 -c:v copy mono.mp4

Left channel to stereo:

ffmpeg -i video.mp4 -map_channel 0.1.0 -map_channel 0.1.0 -c:v copy stereo.mp4

If you want to use the right channel, write 0.1.1 instead of 0.1.0.

Working with ffmpeg version 3.1.3.

qubodup

Posted 2014-01-16T13:32:09.870

Reputation: 3 736

aka how to fix shadowplay right channel corruption bug – Pyrolistical – 2017-09-15T19:32:46.993

Worth to mention is that when using with -c:a copy audio will not be modified even though you'd like to have direct copy of single channel. – termil0r – 2019-02-20T19:59:00.687

4

The following is a confirmed working example with ffmpeg version 2.4.1-tessus:

ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav

More info on FFMPEG's Audio Channel Page.

user49692

Posted 2014-01-16T13:32:09.870

Reputation: 153

BTW for anyone needing the extra step of going back to stereo but having both channels stay full volume (i.e., basically copying the left channel overtop the right channel), you can do ffmpeg -i inputfile.wav -map_channel 0.0.0 -map_channel 0.0.0 outputfile.wav – Kev – 2016-09-07T07:36:46.697

2

Manipulating audio channels with ffmpeg

Chapter Mute a channel

This example will mute the first channel (the left channel) but keep the second channel as is:

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

in your case its need to mute right channel. right?

ArcherGodson

Posted 2014-01-16T13:32:09.870

Reputation: 1 387

Unrecognized option 'map_channel'. – Eric – 2014-01-16T14:11:41.883

1

@Eric I'm guessing (since you haven't included the output) that your ffmpeg version is too old, or it's actually from Libav and not FFmpeg. Try with a newer one: http://ffmpeg.org/download.html

– slhck – 2014-01-16T14:34:35.883

@ArcherGodson - Can we UnMute the muted channel back by modifying same ffmpeg coammnd – Prakash V Holkar – 2014-05-21T08:37:04.360

2

I solved the problem using the last version of Ffmpeg (2.0.1). The following command line makes the work:

/home/eric/buildsys/ffmpeg-2.0.1/ffmpeg -i 00402.MTS -s 1280x720 -ss 0:00:05.38608 -vcodec libxvid -qscale:v 2 -acodec ac3 -ar 48000 -ab 256k -t 0:00:06.61391 -af pan=1:c0=c0 m001_mono.avi

Btw, this post was very instructive!

Eric

Posted 2014-01-16T13:32:09.870

Reputation: 201