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 |
|
|
#1 | Link |
|
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? |
|
|
|
|
|
#2 | Link | ||
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,431
|
Quote:
If you use NeroAacEnc the input channel order must be FL, FR, FC, LF, BL, BR. Quote:
Lt = 0.3254xFL + 0.2301xFC + 0.2818xBL + 0.1627xBR Rt = 0.3254xFR + 0.2301xFC - 0.1627xBL - 0.2818xBR |
||
|
|
|
|
|
#3 | Link |
|
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. |
|
|
|
|
|
#4 | Link | |
|
ffx264/ffhevc author
![]() Join Date: May 2007
Location: /dev/video0
Posts: 2,083
|
Quote:
__________________
The Cyberpunk Database || NTP & NTS Time Server || Mirror Services ffhevc || ffx264 || ffxvid |
|
|
|
|
|
|
#5 | Link |
|
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? |
|
|
|
|
|
#6 | Link | |
|
ffx264/ffhevc author
![]() Join Date: May 2007
Location: /dev/video0
Posts: 2,083
|
Quote:
__________________
The Cyberpunk Database || NTP & NTS Time Server || Mirror Services ffhevc || ffx264 || ffxvid |
|
|
|
|
|
|
#7 | Link |
|
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? |
|
|
|
|
|
#8 | Link | |
|
ffx264/ffhevc author
![]() Join Date: May 2007
Location: /dev/video0
Posts: 2,083
|
Quote:
__________________
The Cyberpunk Database || NTP & NTS Time Server || Mirror Services ffhevc || ffx264 || ffxvid |
|
|
|
|
|
|
#9 | Link |
|
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. |
|
|
|
|
|
#10 | Link |
|
ffx264/ffhevc author
![]() 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
__________________
The Cyberpunk Database || NTP & NTS Time Server || Mirror Services ffhevc || ffx264 || ffxvid Last edited by microchip8; 28th April 2008 at 00:45. |
|
|
|
|
|
#11 | Link | |
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,431
|
Quote:
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 |
|
|
|
|
|
|
#12 | Link |
|
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. |
|
|
|
|
|
#13 | Link |
|
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). |
|
|
|
|
|
#14 | Link | ||
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,431
|
Quote:
Quote:
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 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. |
||
|
|
|
|
|
#15 | Link |
|
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 |
|
|
|
|
|
#16 | Link | |
|
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,431
|
Quote:
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). |
|
|
|
|
![]() |
|
|