Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > General > Audio encoding
Register FAQ Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 27th April 2008, 18:08   #1  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
DPLII downmix AC3/DTS/FLAC to stereo AAC problems

I'm having some trouble converting 5.1 AC3/DTS/FLAC audio to Dolby Prologic II stereo AAC. I've posted this to Hydrogenaudio, but thought I'd give this a go here too - apologies for the slight cross-post.

I'm trying to convert 5.1 AC3/DTS/FLAC movie soundtracks to stereo AAC (in order to play them on an Xbox 360). I'll be outputting to a receiver which does Dolby Prologic II decoding and is hooked up to a 5.1 setup so I'd like to create a DPLII downmix in the AAC file.

This is on Linux, and I'm thinking my best bet is mplayer to do the decoding / downmixing and then neroAacEnc to encode to AAC. mplayer doesn't seem to have any built in downmxing presets, but it does support a "pan" audio filter which lets you specify how each channel gets mixed. Am I right in thinking what I need to do to create a DPLII downmix is use the following mix of channels:

# Dolby Pro Logic II Left Right Center Rear Left Rear Right
# Left Total 1.000 0.000 0.707 -0.8165 -0.5774
# Right Total 0.000 1.000 0.707 0.5774 0.8165

I'm using the following channel mappings for various codecs - are these correct (I've just got them through some Googling
# AAC, DTS: FC , FL , FR , SL , SR , LFE
# AC3: FL, FC, FR, SL, SR, LFE
# FLAC: FL, FR, FC, LFE, SL, SR

I'm trying it using that, and I get audio which sounds garbled in high-volume bits (as if there was clipping). Does that mean I need to normalize the audio too before passing it to neroAacEnc?

My mplayer command is:
mplayer input.dts -vc null -vo null -ao pcm:fast:file=output.wav -af pan:2:0.707:0.707:1:0:0:1:-0.8165:0.5774:-0.5774:0.8165:0:0

And I'm then using neroAacEnc:
neroAacEnc -ignorelength -lc -q 0.5 -if input.wav -of output.m4a

Am I right in thinking that the AAC file output should sound fine when played on normal stereo speakers, as well as getting some surround effects in a surround setup through a DPLII-compatible receiver?
The Belgain is offline   Reply With Quote
Old 27th April 2008, 21:40   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 7,431
Quote:
Originally Posted by The Belgain View Post
I'm using the following channel mappings for various codecs - are these correct (I've just got them through some Googling
# AAC, DTS: FC , FL , FR , SL , SR , LFE
# AC3: FL, FC, FR, SL, SR, LFE
# FLAC: FL, FR, FC, LFE, SL, SR
I don't know for what you need the internal channel order of codecs. The uncompressed order, when you need apply the downmix, is FL, FR, FC, LF, BL, BR. Obtain this order is a decoder job and convert to internal order is a encoder job.

If you use NeroAacEnc the input channel order must be FL, FR, FC, LF, BL, BR.

Quote:
I'm trying it using that, and I get audio which sounds garbled in high-volume bits (as if there was clipping). Does that mean I need to normalize the audio too before passing it to neroAacEnc?
Of course, you must use a normalized matrix to don't cut the high peaks. I recommend you this one:
Lt = 0.3254xFL + 0.2301xFC + 0.2818xBL + 0.1627xBR
Rt = 0.3254xFR + 0.2301xFC - 0.1627xBL - 0.2818xBR
tebasuna51 is offline   Reply With Quote
Old 27th April 2008, 23:20   #3  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
Thanks for the response.

I'm not sure about the channel ordering - I agree that what you say sounds like how it should work, however mplayer's docs don't seem to be quite consistent with that. See http://www.mplayerhq.hu/DOCS/HTML/en...hannels-mixing which says: "Beware that not all multichannel audio files have the same channel order! This example demonstrates downmixing a file with the same channels as AC-3 5.1:". I guess it might be worth me asking on the mplayer mailing lists if no-one here has experience using mplayer to do this.

I'll try using a normalized matrix and see if that helps with the distortion - hopefully it should do.
The Belgain is offline   Reply With Quote
Old 27th April 2008, 23:33   #4  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 2,083
Quote:
Originally Posted by The Belgain View Post
Thanks for the response.

I'm not sure about the channel ordering - I agree that what you say sounds like how it should work, however mplayer's docs don't seem to be quite consistent with that. See http://www.mplayerhq.hu/DOCS/HTML/en...hannels-mixing which says: "Beware that not all multichannel audio files have the same channel order! This example demonstrates downmixing a file with the same channels as AC-3 5.1:". I guess it might be worth me asking on the mplayer mailing lists if no-one here has experience using mplayer to do this.

I'll try using a normalized matrix and see if that helps with the distortion - hopefully it should do.
latest SVN version of MEncoder/MPlayer has implemented channel reordering which correctly maps channels when doing AC3 -> AAC encoding. All you have to do is use the -channels 6 option
microchip8 is offline   Reply With Quote
Old 27th April 2008, 23:37   #5  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
But I'm looking for downmixing to stereo, not 5.1 AAC encoding (as this is intended for an Xbox 360, which doesn't support 5.1 AAC).

One other point I've noticed looking at the mplayer docs is that the pan filter only seems to support positive values in the matrix, not negative ones. Does that mean I can't use it to get a DPLII downmix?
The Belgain is offline   Reply With Quote
Old 27th April 2008, 23:40   #6  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 2,083
Quote:
Originally Posted by The Belgain View Post
But I'm looking for downmixing to stereo, not 5.1 AAC encoding (as this is intended for an Xbox 360, which doesn't support 5.1 AAC).

One other point I've noticed looking at the mplayer docs is that the pan filter only seems to support positive values in the matrix, not negative ones. Does that mean I can't use it to get a DPLII downmix?
the channel reordering is also for stereo encodings. Have you tried doing a small test and see if it works without the pan filter?
microchip8 is offline   Reply With Quote
Old 27th April 2008, 23:47   #7  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
So are you saying I should just be able to do the following. I'm assuming I do need -channels 2 here right?

mplayer <input_file> -vc null -vo null -ao pcm:fast:file=output.wav -channels 2

Is this decoder-specific (i.e. will it work for ac3, dts, flac inputs)? When you say it gives correct channel mapping, is this a DPLII downmix? Or something else?
The Belgain is offline   Reply With Quote
Old 27th April 2008, 23:55   #8  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 2,083
Quote:
Originally Posted by The Belgain View Post
So are you saying I should just be able to do the following. I'm assuming I do need -channels 2 here right?

mplayer <input_file> -vc null -vo null -ao pcm:fast:file=output.wav -channels 2

Is this decoder-specific (i.e. will it work for ac3, dts, flac inputs)? When you say it gives correct channel mapping, is this a DPLII downmix? Or something else?
I just went through the channel reordering code and I might have been wrong at first sight. It seems channels reordering is only implemented for 5 and 5.1 sound. I'm not sure if it will downmix to DPLII. Best way to find out is to do a small test and see if it works... the -channels option tells the decoder how many channels to export, if input channels is bigger than output channels, it downmixes
microchip8 is offline   Reply With Quote
Old 27th April 2008, 23:58   #9  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
Hmm.. yeah, that's what I figured. The docs for the channels filter here: http://www.mplayerhq.hu/DOCS/man/en/...UDIO%20FILTERS suggets that all it'll do is drop the centre/LFE/surround channels, which is not what I want.

I'll have a play.
The Belgain is offline   Reply With Quote
Old 28th April 2008, 00:36   #10  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 2,083
there are two channels filters in MEncoder. -channels and -af channels. The first one is used to tell the decoder how many channels to output. The second one is used for channel reordering and downmixing. So if you have 5.1 audio and want to downmix it to 2 channels, you could use...

mplayer inputfile -channels 6 -af channels=2 -vc null -vo null -ao pcm:fast:file=audio.wav

I haven't tried it myself, but i think it should work. you may need to remap the other channels to put them into 2 channels

Last edited by microchip8; 28th April 2008 at 00:45.
microchip8 is offline   Reply With Quote
Old 28th April 2008, 17:16   #11  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 7,431
Quote:
Originally Posted by The Belgain View Post
One other point I've noticed looking at the mplayer docs is that the pan filter only seems to support positive values in the matrix, not negative ones. Does that mean I can't use it to get a DPLII downmix?
I download MPlayer-mingw32-1.0rc2 for Windows and make some test.

You are right. The -af pan= filter ignore the sign in coeficients then you can't obtain a DPL or DPLII downmix with this method.

BTW, mplayer decode each source with different channel mapping:
Code:
ogg     -> FL,FC,FR,BL,BR,LF (wrong)
aac,mp4 -> FC,FL,FR,BL,BR,LF (wrong)
ac3,dts -> FL,FR,BL,BR,FC,LF (wrong)
wma,flac-> FL,FR,FC,LF,BL,BR ok
Seems mplayer still don't work with multichannel.
tebasuna51 is offline   Reply With Quote
Old 28th April 2008, 17:25   #12  |  Link
madshi
Registered Developer
 
Join Date: Sep 2006
Posts: 9,140
If all else fails you can try using eac3to to do the downmix. eac3to is a Windows tool, but I've been told it runs ok under Wine. E.g.

"eac3to source.flac dest.flac -down2"

This should convert the multichannel source file to a 2 channel DPLII downmix. Supported source formats are e.g. flac, dts, ac3 (use the "-libav" switch to use libav for DTS/AC3 decoding instead of the default; the default will probably not work in Linux). Supported (lossless) output formats are e.g. flac and wav.
madshi is offline   Reply With Quote
Old 28th April 2008, 23:11   #13  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
tebasuna51: thanks for the confirmation - that's what I thought too. Does that mean multichannel output is broken in mplayer for use as a normal player, as well as when using it for wav file output? That's a little disappointing really. Is this an mplayer of ffmpeg (libavcodec) issue? I'll also post to mplayer-users to double-check double-check that pan= really doesn't support negative coeffs - if it doesn't I may try to have a look at the code and maybe add it.

madshi: thanks for the suggestion, but I'm really after a Linux (ideally crossplatform) app here as I'm making a little wrapper app to automatically convert mkvs for the Xbox 360 / PS3 and would like it to have reasonable dependencies (wine + a Windows app not being great).
The Belgain is offline   Reply With Quote
Old 29th April 2008, 00:08   #14  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 7,431
Quote:
Originally Posted by The Belgain View Post
Does that mean multichannel output is broken in mplayer for use as a normal player, as well as when using it for wav file output?
At least the release 1.0rc2 for Windows produce unusable wav output decoding ac3, dts, ogg, aac/mp4/m4a multichannel.

Quote:
That's a little disappointing really. Is this an mplayer of ffmpeg (libavcodec) issue?
I think is a ffmpeg issue. But there are differences, in Mplayer docs:
Code:
3.6.2. Channel manipulation
3.6.2.1. General information
Unfortunately, there is no standard for how channels are ordered.
The orders listed below are those of AC-3 and are fairly typical; try them
and see if your source matches. Channels are numbered starting with 0.
...
surround 5.1
   0. left front
   1. right front
   2. left rear
   3. right rear
   4. center front
   5. subwoofer
Like the ac3, dts mplayer output. But I never see before this order, I see FL,FC,FR,BL,BR,LF (like ogg) and also LF,FL,FC,FR,BL,BR like some ffmpeg decoders.

There are also some patches to decode ac3 with correct channelmapping in this thread.

Seems the official ffmpeg/mplayer developers remains at 20th century, I never see, in this century, something like:
"Unfortunately, there is no standard for how channels are ordered."

Of course there are a standard for uncompressed wav files and is well know for audio developers. Close the eyes don't leads nowhere.

Last edited by tebasuna51; 30th April 2008 at 01:54.
tebasuna51 is offline   Reply With Quote
Old 29th April 2008, 23:51   #15  |  Link
The Belgain
Registered User
 
Join Date: Apr 2002
Location: UK
Posts: 335
By the way, what standard are you referring to for 5.1 channel ordering in multichannel wav files? The wav specs I can find by googling don't seem to mandate this at all, and indeed this document about WAVEFORMATEXTENSIBLE states that there is an issue with a lack of convention for multichannel wavs: http://msdn.microsoft.com/en-us/libr...96(VS.85).aspx. It looks like the wav file format is intended to be generic and extensible.

Last edited by The Belgain; 30th April 2008 at 00:08. Reason: Added link
The Belgain is offline   Reply With Quote
Old 30th April 2008, 01:53   #16  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 7,431
Quote:
Originally Posted by The Belgain View Post
By the way, what standard are you referring to for 5.1 channel ordering in multichannel wav files? The wav specs I can find by googling don't seem to mandate this at all, and indeed this document about WAVEFORMATEXTENSIBLE states that there is an issue with a lack of convention for multichannel wavs: http://msdn.microsoft.com/en-us/libr...96(VS.85).aspx. It looks like the wav file format is intended to be generic and extensible.
What else?
I have copies of WAVEFORMATEXTENSIBLE specs from 1999 (I don't know if was written before), then the problem (undefined order) was solved in the past century.

The wav format can be flexible but can't be undefined.
Is true, don't exist a mandate to write wav, with standard header, in a determined channel order. But you need a mandate to solve a problem when you know the solution?

Don't exist a mandate but yes a standard. Try to play a multichannel wav (with standard header) in any player with 5.1 audio equipment and listen, this is the default order.

All modern decoders/encoders accept that:
the uncompressed output/input audio data default channel order is always FL,FR,FC,LF,BL,BR,... (the same with WAVEFORMATEXTENSIBLE wav header, standard header or raw data).
tebasuna51 is offline   Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.