-   Linux - Software (
-   -   Converting 6 channel audio to 2 channel audio in a MKV file (

J_Humphrey 11-30-2009 03:19 AM

Converting 6 channel audio to 2 channel audio in a MKV file
How would I go about demuxing a 6 channel audio from a mkv, down mix it to 2 channel, then mux the video and sound back together?

My computer has trouble downmixing on the fly as it causes major lag and stuttering during playback.

Here's the relevent data from "ffmpeg -i file.mkv"


Stream #0.0(eng): Video: h264, yuv420p, 1920x1080, PAR 1:1 DAR 16:9, 23.98 tbr, 1k tbn, 47.95 tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 6 channels, s16

Oh, and I'd prefer it to be on command line, but if theres a gui app that makes it much easier, I'd be willing to use that too.


H_TeXMeX_H 11-30-2009 04:35 AM

Newer versions of ffmpeg should have no problem with it. I remember older versions failed with an error if you tried 6 -> 2 channel downmix.

So, you still want to use ac3 in the output ? I wouldn't, it's a waste of space.

Anyway I recommend:


ffmpeg -i file.mkv -vcodec copy -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 output.mkv
You can also use mencoder:


mencoder input.mkv -oac mp3lame -lameopts q=2 -ovc copy -o output.mkv


mencoder input.mkv -oac faac -faacopts quality=500 -ovc copy -o output.mkv

H_TeXMeX_H 01-16-2010 09:38 AM

Just to be more complete, it can also be done this way (recently tested this, and it works, in case ffmpeg doesn't want to do it):


mkvextract tracks input.mkv 2:sixchannel.aac
faad -d -a twochannel.aac sixchannel.aac
mkvmerge -o output.mkv -A input.mkv twochannel.aac

Check using mkvinfo to see which track is the audio track, because it might not be 2.

Shadow_7 01-16-2010 11:03 AM

ffmpeg -vn -i input.mkv -acodec copy -y audio_original.format
sox audio_original.format -c 2 stereo.format

and remux. I've found ffmpeg to be a little wonky with audio. i.e. If I use ffmpeg to trim / extract a particular time segment of audio, it'll differ from other more accurate applications. It'll do it, and it'll be close. But when I was trying to use ffmpeg to extract an element to sync with an external audio source, I had real issues with lining up that external audio +/- 1/1000th of second with ffmpeg. With sox, it's spot on everytime, shift the cut points and it stays linear. Shift it with ffmpeg and your sync point changes. Fractions of a second, but still annoying(+/- 0.050 aka 1/2 of 1/10th of a second but noticeable drumming at 60p in HD). </rant>

ffmpeg does decent with audio ONLY.
ffmpeg does decent with video ONLY.
ffmpeg is not that decent when doing both video and audio at the same time. IMHO

Basically -acodec copy and/or -vcodec copy the original content, then handle individually until the last possible moment.

H_TeXMeX_H 01-16-2010 11:27 AM

Well, for a/v sync issues make sure to use the '-async' option with ffmpeg (with the sample rate of the audio as the parameter), that should prevent any kind of a/v desync. I've tested it, and I don't notice any a/v desync if you use this option.

kbeii2000 01-25-2011 11:40 AM

Using this command line:
ffmpeg -i file.mkv -vcodec copy -acodec libmp3lame -ab 160k -ar 48000 -async 48000 -ac 2 output.mkv
I get the error:
Resampling with input channels greater than 2 unsupported.
Can not resample 6 channels @ 48000 Hz to 2 channels @ 48000 Hz

This works fine:
mencoder input.mkv -oac mp3lame -lameopts q=2 -ovc copy -o output.mkv
but the issue is I need to use ffmpeg because it is what the program is using to transcode.

I know this is an old post, but hopfully someone will see activity.

H_TeXMeX_H 01-25-2011 12:08 PM

See the bottom of this page:

kbeii2000 01-26-2011 07:04 AM

Thank you for the information and direction. Would these work for on the fly transcoding?

H_TeXMeX_H 01-26-2011 12:37 PM

On the fly ? Like how ? Piping stuff ? Yeah, just use '-'.

sfabzx 10-21-2013 04:27 AM

To change 6 channel audio to 2 channel audio in a MKV file, I know a very nice guide. Google search "Convert between 6/5.1Channel, 2 Channel/Stereo and Mono" to get it.

All times are GMT -5. The time now is 11:51 AM.