LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-30-2009, 04:19 AM   #1
J_Humphrey
LQ Newbie
 
Registered: Mar 2008
Location: West Coast
Distribution: Slack13
Posts: 20

Rep: Reputation: 2
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"

Code:
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.


Thanks
 
Old 11-30-2009, 05:35 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
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:

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

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

Code:
mencoder input.mkv -oac faac -faacopts quality=500 -ovc copy -o output.mkv
 
Old 01-16-2010, 10:38 AM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
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):

Code:
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.
 
Old 01-16-2010, 12:03 PM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 875Reputation: 875Reputation: 875Reputation: 875Reputation: 875Reputation: 875Reputation: 875
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.
 
Old 01-16-2010, 12:27 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
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.
 
Old 01-25-2011, 12:40 PM   #6
kbeii2000
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Rep: Reputation: Disabled
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.
 
Old 01-25-2011, 01:08 PM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
See the bottom of this page:
http://draconishinobi.50webs.com/linux/encoding.html
 
Old 01-26-2011, 08:04 AM   #8
kbeii2000
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Rep: Reputation: Disabled
Thank you for the information and direction. Would these work for on the fly transcoding?
 
Old 01-26-2011, 01:37 PM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
On the fly ? Like how ? Piping stuff ? Yeah, just use '-'.
 
Old 10-21-2013, 05:27 AM   #10
sfabzx
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Audio Channel... slack3r Slackware 1 06-19-2007 08:45 PM
Audio Channel Imbalance punchthemonkey94 Linux - Software 1 04-17-2007 01:02 PM
Is multi channel audio possible ? mreinecker Fedora 15 05-23-2005 04:42 PM
CD audio no right channel system ok robby737 Linux - Newbie 0 07-29-2004 11:32 AM
6 channel audio with linux bignester Linux - Software 3 08-23-2003 12:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration