Log in

View Full Version : MeGUI 6 Channel AC3 to 3 Channel AAC


kshawkeye
7th November 2010, 04:03
Hey, MeGUI has a problem converting a 6 Channel AC3 audio file into a 3 Channel AAC (Stereo).

Half of the time it fails with Exception message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. and when it doesn't fail the output AAC file is still 6 channel.

Ive tried to check "Force Decoding via DirectShow" to no avail. I have done every selection to downmix multichannel to ___ yet nothing seems to change the channel output.

Any ideas?

Sharktooth
7th November 2010, 04:26
3 channels STEREO? are you serious?
maybe you miss the stereophonic sound definition (http://en.wikipedia.org/wiki/Stereophonic_sound)...
in any case 3 channels is not a supported configuration by the encoder.

kshawkeye
7th November 2010, 04:40
Haha Jesus Christ, why does everyone on Doom9 feel that they need to correct unimportant information the rudest way possible to get an ego boost?

Stereo can be in 3 channels, read: http://en.wikipedia.org/wiki/Dolby_Digital and search for "3-channel stereo".

Regardless, this is not the issue at hand. MeGUI is not converting 6 channel AC3 to 3 channel AAC and I need some help on that.

As far as "in any case 3 channels is not a supported configuration by the encoder." I didn't think it was either, but I got MeGUI to work one time, and the resulting audio stream was 3 channel, while I myself thought that it would be a 2 channel.

Sharktooth
7th November 2010, 04:47
Dolby Digital is different from Stereo. it's a completely different animal.
however, as i said 3 channels is not a supported audio encoder configuration and megui can do nothing about that. it's just the aac encoder(s) do not support that channel configuration.

kshawkeye
7th November 2010, 04:51
I edited my last post to respond. I got it to work one time, and the audio stream was in fact AAC 3 channel (to my surprise as well). I just want a normal 2 channel stereo AAC output, down mixed from a 6 channel AC3, yet I have no idea how MeGUI would have to be configured to achieve this.

Sharktooth
7th November 2010, 05:25
ensure you're using neroaac for better quality.
click on the config button on the audio profile. on the "output channels" dropdown, select "downmix multichannel to stereo".
configure the rest of settings (bitrate/quality/etc...) and save the preset.

edit: you may also want to use one of the "bundled" AAC stereo presets (those with no "multichannel" in the name).

kshawkeye
7th November 2010, 05:54
I am using neroaac, and I have tried that exact thing but the problem still occurs.

kshawkeye
7th November 2010, 06:12
Here is a log.

[Information] Log for job1 (audio, Audio In.ac3 -> Audio Out.mp4)
-[Information] [11/7/2010 12:57:13 AM] Started handling job
-[Information] [11/7/2010 12:57:13 AM] Preprocessing
-[NoImage] Avisynth script
--[NoImage] LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\NicAudio.dll")
--[NoImage] NicAc3Source("Audio In.ac3")
--[NoImage] DelayAudio(-9.0/1000.0)
--[NoImage] 6<=Audiochannels(last)?x_stereo19bb92c31a624588bfdb3f16c0ae9e25(ConvertAudioToFloat(last)):last
--[NoImage] SSRC(48000)
--[NoImage] Normalize()
--[NoImage] return last
--[NoImage] function x_stereo19bb92c31a624588bfdb3f16c0ae9e25(clip a)
--[NoImage] {
--[NoImage] fl = GetChannel(a, 1)
--[NoImage] fr = GetChannel(a, 2)
--[NoImage] c = GetChannel(a, 3)
--[NoImage] lfe = GetChannel(a, 4)
--[NoImage] sl = GetChannel(a, 5)
--[NoImage] sr = GetChannel(a, 6)
--[NoImage] l_sl = MixAudio(fl, sl, 0.2929, 0.2929)
--[NoImage] c_lfe = MixAudio(lfe, c, 0.2071, 0.2071)
--[NoImage] r_sr = MixAudio(fr, sr, 0.2929, 0.2929)
--[NoImage] l = MixAudio(l_sl, c_lfe, 1.0, 1.0)
--[NoImage] r = MixAudio(r_sr, c_lfe, 1.0, 1.0)
--[NoImage] return MergeChannels(l, r)
--[NoImage] }
-[NoImage] Commandline used: -ignorelength -br 128000 -if - -of "{0}"
-[Information] [11/7/2010 12:57:13 AM] Encoding started
-[Information] [11/7/2010 12:57:13 AM] Encode thread started
-[Information] [11/7/2010 12:57:13 AM] Avisynth script environment opened
-[Information] [11/7/2010 12:57:13 AM] Script loaded
-[Information] Output Decoder
--[NoImage] Channels: 5
--[NoImage] Bits per sample: 32
--[NoImage] Sample rate: 48000
-[NoImage] Commandline: C:\Program Files (x86)\MeGUI\tools\neroaac\neroAacEnc.exe -ignorelength -br 128000 -if - -of "Audio Out.mp4"
-[Information] [11/7/2010 12:57:25 AM] Encoder process started

And here is the output file MediaInfo

Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 4
Format profile : LC
Format settings, SBR : Yes
Format settings, PS : No
Codec ID : 40
Duration : 24mn 58s
Bit rate mode : Variable
Bit rate : 128 Kbps
Maximum bit rate : 176 Kbps
Channel(s) : 5 channels
Channel positions : Front: L C R, Side: L R
Sampling rate : 48.0 KHz
Stream size : 22.8 MiB (99%)
Encoded date : UTC 2010-11-07 04:57:57
Tagged date : UTC 2010-11-07 05:00:53

And here is how I had my configure set up:

Force Decoding via DirectShow: Unchecked
Apply Dynamic Range Compression: Unchecked
Output Channels: Downmix multichannel to Stereo
SampleRate: Change to 48000 Hz
Normalize Peaks to 100: Checked
Adaptive Bitrate @ 128 kbit/s: Selected
AAC Profile: Automatic

Also, when looking more closely at the MediaInfo I have noticed something.

The audio is 1498 seconds long, and the bitrate is overall 129, so the file size should be around 23.22 MB for a 2 channel, which it is. So I'm confused, is it actually two channel, and MediaInfo is wrong, or am I missing/getting something wrong.

Sharktooth
7th November 2010, 15:06
from what i see, mediainfo reports 5 channels (no LFE) and the procedure you used in megui is correct.
open the audio file in VLC and click on stream properties then look at the channels.

tebasuna51
7th November 2010, 20:00
You need put a MediaInfo of your input ac3.
Isn't a 5.1 (6 channels) and the downmix function is not activated:

6<=Audiochannels(last)?x_stereo...:last

To downmix a 5 channels ac3 we need know what kind of channel configuration you have. For 5 channels can be:
2/2.1 L R SL SR LFE
3/1.1 L C R S LFE
3/2.0 L C R SL SR

Edit: BTW, you can always use as input, instead "Audio In.ac3", an avs script like this:

LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\NicAudio.dll")
NicAc3Source("Audio In.ac3", 2)

Then NicAudio do the appropriate downmix to 2.0 (Dolby ProLogic)

kshawkeye
7th November 2010, 20:26
from what i see, mediainfo reports 5 channels (no LFE) and the procedure you used in megui is correct.
open the audio file in VLC and click on stream properties then look at the channels.

VLC says "Channels: 3F2R" which I'm guessing means 3 front 2 rear, which means it's 5 channel.

Here is the MediaInfo for the AC3:
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Duration : 24mn 58s
Bit rate mode : Constant
Bit rate : 448 Kbps
Channel(s) : 5 channels
Channel positions : Front: L C R, Side: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Stream size : 80.0 MiB (100%)

tebasuna51
8th November 2010, 00:34
VLC says "Channels: 3F2R" which I'm guessing means 3 front 2 rear, which means it's 5 channel.
Then use this .avs like audio input file:
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\NicAudio.dll")
a = NicAc3Source("Audio In.ac3")
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
blr = GetChannel(a, 4, 5)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
MixAudio(lrc, blr, 1.0, 0.3694)

Don't forget the Delay and Normalize, the Change to 48000 Hz is not needed.

kshawkeye
9th November 2010, 06:12
Sorry for the noob question, but how do I load that .avs into MeGUI to convert the audio?

tebasuna51
9th November 2010, 12:35
MeGUI -> Input tab -> Audio section -> Track 1 tab -> Audio input: your .avs
Put the Delay if any.
Encoder settings -> Config: check only Normalize (Keep channels and samplerate)

kshawkeye
10th November 2010, 00:33
Thanks a lot for your help, I didn't realize that I could use a AVS for the input.

I believe this is a problem with MeGUI, shouldn't something be done about it, so people don't need to create there own .avs? (not that I'm lazy, but I know some people are and I just want to make MeGUI better.)

tebasuna51
10th November 2010, 01:20
I believe this is a problem with MeGUI, shouldn't something be done about it, so people don't need to create there own .avs?

The first pass must be done by AviSynth, we need a new audio property ChannelMask to know what channels are present.
NicAudio know the channels but can't pass the info to AviSynth to make the proper downmix.

kshawkeye
10th November 2010, 01:40
Okay, so what do others do if they have the same issue, read this thread? If the downmix doesn't work then why is it an option?

Sharktooth
10th November 2010, 03:13
the downmix DOES work with common audio sources.
the fact we dont have the crystel ball to guess the audio channels is another fact and we can do almost nothing about that.
that is true for other softwares too.

kshawkeye
10th November 2010, 03:34
What common audio sources are 6 channel that need to be downmixed? I love MeGUI, it's my favorite encoder, and I'm not trying to be a jerk about this, I just don't understand how there is a downmix option that doesn't work with ac3 (in my mind one of the main surround sound channel formats, other than DTS).

Is there anything that I could do to help improve the support for ac3 in MeGUI?

Sharktooth
10th November 2010, 03:56
5.1ch -> 2ch works... and that's what most users need.
unusual channel configuration could not work.
actually you (and we) can do nothing unless proper support for multichannel audio is implemented in avisynth.

tebasuna51
10th November 2010, 15:02
...
actually you (and we) can do nothing unless proper support for multichannel audio is implemented in avisynth.
Yes, seems still pending http://forum.doom9.org/showthread.php?t=137991

But we can cover many unusual channel configuration with some MeGUI changes.

When select Downmix multichannel to Stereo, MeGUI add this AviSynth code:
6<=Audiochannels(last)?x_stereob9815f83aa5b42afb755a422d224d5e6(ConvertAudioToFloat(last)):last
...
function x_stereob9815f83aa5b42afb755a422d224d5e6(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
c = GetChannel(a, 3)
lfe = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l_sl = MixAudio(fl, sl, 0.2929, 0.2929)
c_lfe = MixAudio(lfe, c, 0.2071, 0.2071)
r_sr = MixAudio(fr, sr, 0.2929, 0.2929)
l = MixAudio(l_sl, c_lfe, 1.0, 1.0)
r = MixAudio(r_sr, c_lfe, 1.0, 1.0)
return MergeChannels(l, r)
}
We can replace the code with:
(please forget the useless ramdom number)
6<=Audiochannels(last)?c6_stereo(ConvertAudioToFloat(last)):last
5 =Audiochannels(last)?c5_stereo(ConvertAudioToFloat(last)):last
4 =Audiochannels(last)?c4_stereo(ConvertAudioToFloat(last)):last
3 =Audiochannels(last)?c3_stereo(ConvertAudioToFloat(last)):last
...
function c6_stereo(clip a) # 5.1 Channels L,R,C,LFE,SL,SR -> stereo + LFE
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lfe = GetChannel(a, 4, 4)
slr = GetChannel(a, 5, 6)
lrc = MixAudio(flr, fcc, 0.2929, 0.2071)
lrc = MixAudio(lrc, lfe, 1.0, 0.2071)
return MixAudio(lrc, slr, 1.0, 0.2929)
}
function c5_stereo(clip a) # 5 Channels L,R,C,SL,SR -> Stereo
{ # also L,R,LFE,SL,SR
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
slr = GetChannel(a, 4, 5)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
return MixAudio(lrc, slr, 1.0, 0.3694)
}
function c4_stereo(clip a) # 4 Channels Quadro L,R,SL,SR -> Stereo
{
flr = GetChannel(a, 1, 2)
slr = GetChannel(a, 3, 4)
return MixAudio(flr, slr, 0.5, 0.5)
}
function c3_stereo(clip a) # 3 Channels L,R,C or L,R,S or L,R,LFE -> Stereo
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
return MixAudio(flr, fcc, 0.5858, 0.4142)
}

When select Downmix multichannel with Dolby Pro Logic:
6<=Audiochannels(last)?c6_dpl(ConvertAudioToFloat(last)):last
5 =Audiochannels(last)?c5_dpl(ConvertAudioToFloat(last)):last
4 =Audiochannels(last)?c4_dpl(ConvertAudioToFloat(last)):last
3 =Audiochannels(last)?c3_dpl(ConvertAudioToFloat(last)):last
...
function c6_dpl(clip a) # 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
lrc = MixAudio(flr, fcc, 0.3205, 0.2265)
bl = MixAudio(sl, sr, 0.2265, 0.2265)
br = Amplify(bl, -1.0)
slr = MergeChannels(bl, br)
return MixAudio(lrc, slr, 1.0, 1.0)
}
function c5_dpl(clip a) # 5 Channels L,R,C,SL,SR -> Dolby ProLogic
{ # also L,R,LFE,SL,SR then mix dpl+LFE
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
lrc = MixAudio(flr, fcc, 0.3205, 0.2265)
bl = MixAudio(sl, sr, 0.2265, 0.2265)
br = Amplify(bl, -1.0)
slr = MergeChannels(bl, br)
return MixAudio(lrc, slr, 1.0, 1.0)
}
function c4_dpl(clip a) # 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = GetChannel(a, 4)
bl = MixAudio(sl, sr, 0.2929, 0.2929)
br = Amplify(bl, -1.0)
slr = MergeChannels(bl, br)
return MixAudio(flr, slr, 0.4142, 1.0)
}
function c3_dpl(clip a) # 3 Channels L,R,S -> Dolby ProLogic
{ # for L,R,C or L,R,LFE use always -> stereo
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = Amplify(sl, -1.0)
slr = MergeChannels(sl, sr)
return MixAudio(flr, slr, 0.5858, 0.4142)
}

When select Downmix multichannel with Dolby Pro Logic II:
6<=Audiochannels(last)?c6_dpl2(ConvertAudioToFloat(last)):last
5 =Audiochannels(last)?c5_dpl2(ConvertAudioToFloat(last)):last
4 =Audiochannels(last)?c4_dpl2(ConvertAudioToFloat(last)):last
3 =Audiochannels(last)?c3_dpl2(ConvertAudioToFloat(last)):last
...
function c6_dpl2(clip a) # 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic II
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
bl = MixAudio(sl, sr, 0.2818, 0.1627)
br = MixAudio(sl, sr, -0.1627, -0.2818)
slr = MergeChannels(bl, br)
return MixAudio(lrc, slr, 1.0, 1.0)
}
function c5_dpl2(clip a) # 5 Channels L,R,C,SL,SR -> Dolby ProLogic II
{ # also L,R,LFE,SL,SR then mix dpl2+LFE
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
bl = MixAudio(sl, sr, 0.2818, 0.1627)
br = MixAudio(sl, sr, -0.1627, -0.2818)
slr = MergeChannels(bl, br)
return MixAudio(lrc, slr, 1.0, 1.0)
}
function c4_dpl2(clip a) # 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic II
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = GetChannel(a, 4)
bl = MixAudio(sl, sr, 0.3714, 0.2144)
br = MixAudio(sl, sr, -0.2144, -0.3714)
slr = MergeChannels(bl, br)
return MixAudio(flr, slr, 0.4142, 1.0)
}
function c3_dpl2(clip a) # 3 Channels L,R,S -> Dolby ProLogic (we can't make dpl II)
{ # for L,R,C or L,R,LFE use always -> stereo
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = Amplify(sl, -1.0)
slr = MergeChannels(sl, sr)
return MixAudio(flr, slr, 0.5858, 0.4142)
}

With ac3 input some channel config aren't covered:
3/1.0 (L,R,C,S)
2/1.1 (L,R,LFE,S)
3/0.1 (L,R,C,LFE)
3/1.1 (L,R,C,LFE,S)
But only the first one can be typical (like ouput from a Dolby ProLogic upmix, some VHS audio)

kshawkeye
13th November 2010, 12:27
Wow, I'm going to be honest, some of that was over my head. If we can fix this problem in MeGUI how soon do you think it could get fixed?

Also, I'm curios about where you get the numbers from, such as "lrc = MixAudio(flr, fcc, 0.3254, 0.2301)" the 0.3254 and 0.2301, how do you come up with those and what exactly do they do? (or are those the random numbers you were referring to?)

Also, in the avisynth script you gave me (which worked perfect by the way, thanks a lot) you used 0.3694 and 0.2612, what are these numbers and what do they do/mean?

tebasuna51
13th November 2010, 17:38
The random number is: function x_stereob9815f83aa5b42afb755a422d224d5e6

The coefficients are calcutated values in order to obtain:
- A balanced acustic power similar to original
- Avoid overflows
- Better channel separation with Dolby ProLogic (II) decoders.

Zathor
14th November 2010, 19:07
Thank you very much tebasuna. The avisynth downmix functions have been changed based upon your input and it wil be included in buil 0.3.5.26.

Btw I think it is possible to check the mediainfo information of an audio file so that the input channel config can be revealed. Maybe with this information it is possible to cover all channel configurations. These avisynth functions are way out of my scope and therefore I would be very glad if you can assist once again.

kshawkeye
15th November 2010, 01:19
That's great news, I'm glad that I brought this issue up. I'm using the developer version of MeGUI and I think it might already be included, but haven't had a chance to test it yet.

Any news on how long it could be before it is released with the stable?

tebasuna51
15th November 2010, 02:04
...
Btw I think it is possible to check the mediainfo information of an audio file so that the input channel config can be revealed. Maybe with this information it is possible to cover all channel configurations. These avisynth functions are way out of my scope and therefore I would be very glad if you can assist once again.

MediaInfo inform with the Channel Position info. For a standard 5.1:
Channel Position: 3/2/0.1
3 front channels L,R,C
2 surround channels SL, SR
0 rear channels
1 LFE channel

Here is the relation between Channel Position and Downmix functions needed:
Downmix Downmix Downmix
Num. Channel Function Function Function
Cha. positions Stereo Dolby ProLogic DPL II (EDIT)
--- --------- --------- -------------- --------- -----------
3 3/0/0 c3_stereo c3_stereo c3_stereo
3 2/0/0.1 c3_stereo c3_stereo c3_stereo
3 2/1/0 c3_stereo c3_dpl c3_dpl (or 2/0/1)

4 2/2/0 c4_stereo c4_dpl c4_dpl2 (or 2/0/2)
4 2/1/0.1 c42stereo c42dpl c42dpl (or 2/0/1.1)
4 3/0/0.1 c42stereo c3_stereo c3_stereo
4 3/1/0 c42stereo c43dpl c43dpl (or 3/0/1)

5 3/2/0 c5_stereo c5_dpl c5_dlp2 (or 3/0/2)
5 2/2/0.1 c5_stereo c52dpl c52dlp2 (or 2/0/2.1)
5 3/1/0.1 c52stereo c53dpl c53dpl (or 3/0/1.1)

6 3/2/0.1 c6_stereo c6_dpl c6_dpl2 (or 3/0/2.1)

The new functions are:
function c42stereo(clip a) # 4 Channels L,R,C,LFE or L,R,S,LFE or L,R,C,S -> Stereo
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lfe = GetChannel(a, 4, 4)
clf = MixAudio(fcc, lfe, 0.2929, 0.2929)
return MixAudio(flr, clf, 0.4142, 1.0)
}
function c52stereo(clip a) # 5 Channels L,R,C,LFE,S -> Stereo
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lfe = GetChannel(a, 4, 4)
slr = GetChannel(a, 5, 5)
lrc = MixAudio(flr, fcc, 0.3204, 0.2265)
lfs = MixAudio(lfe, slr, 0.2265, 0.2265)
return MixAudio(lrc, lfs, 1.0, 1.0)
}
function c42dpl(clip a) # 4 Channels L,R,LFE,S -> Dolby ProLogic
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 4)
sr = Amplify(sl, -1.0)
slr = MergeChannels(sl, sr)
return MixAudio(flr, slr, 0.5858, 0.4142)
}
function c43dpl(clip a) # 4 Channels L,R,C,S -> Dolby ProLogic
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
bl = GetChannel(a, 4)
br = Amplify(bl, -1.0)
slr = MergeChannels(bl, br)
flc = MixAudio(flr, fcc, 0.4142, 0.2929)
return MixAudio(flc, slr, 1.0, 0.2929)
}
function c52dpl(clip a) # 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
bl = MixAudio(sl, sr, 0.2929, 0.2929)
br = Amplify(bl, -1.0)
slr = MergeChannels(bl, br)
return MixAudio(flr, slr, 0.4142, 1.0)
}
function c53dpl(clip a) # 5 Channels L,R,C,LFE,S -> Dolby ProLogic
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
bl = GetChannel(a, 5)
br = Amplify(bl, -1.0)
slr = MergeChannels(bl, br)
flc = MixAudio(flr, fcc, 0.4142, 0.2929)
return MixAudio(flc, slr, 1.0, 0.2929)
}
function c52dpl2(clip a) # 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic II
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
bl = MixAudio(sl, sr, 0.3714, 0.2144)
br = MixAudio(sl, sr, -0.2144, -0.3714)
slr = MergeChannels(bl, br)
return MixAudio(flr, slr, 0.4142, 1.0)
}

EDIT:
There are some incongruities in Channel Position info. For instance a 3 channels ac3 L,R,S is informed like 2/1/0.
After decoded to WAVE_FORMAT_EXTENSIBLE (the S channel can only be Back Center Channel) is informed like 2/0/1.
There are also a old discussion: the Surround channels must be considered like Side or Back channels?

Then, talking only with less than 7 channels, always we can consider equivalent x/0/x with x/x/0

Zathor
16th November 2010, 23:25
Thank you very much. I will add this into the next build.

tebasuna51
4th December 2010, 03:54
Thanks to you for your job with MeGUI.

First my mistake with names (c5_dlp2, c52dlp2 must be c5_dpl2, c52dpl2) and also new names (c52dpl2 now c52_dpl2). Now:
Downmix Downmix Downmix
Num. Channel Function Function Function
Cha. positions or Stereo Dolby ProLogic DPL II
--- --------- ------- --------- -------------- ---------
3 3/0/0 c3_stereo c3_stereo c3_stereo
3 2/0/0.1 c3_stereo c3_stereo c3_stereo
3 2/1/0 2/0/1 c3_stereo c3_dpl c3_dpl

4 2/2/0 2/0/2 c4_stereo c4_dpl c4_dpl2
4 2/1/0.1 2/0/1.1 c42_stereo c42_dpl c42_dpl
4 3/0/0.1 c42_stereo c3_stereo c3_stereo
4 3/1/0 3/0/1 c42_stereo c43_dpl c43_dpl

5 3/2/0 3/0/2 c5_stereo c5_dpl c5_dpl2
5 2/2/0.1 2/0/2.1 c5_stereo c52_dpl c52_dpl2
5 3/1/0.1 3/0/1.1 c52_stereo c53_dpl c53_dpl

6 3/2/0.1 3/0/2.1 c6_stereo c6_dpl c6_dpl2

Like you say in your pm, seems there are problems:
"Attempted to read or write protected memory."
with some mix stereo functions, maybe related with the bug detected by Gavino in AviSynth 2.5.8 (http://forum.doom9.org/showthread.php?t=149457)

Then I make a new set of functions, with only mono mix, to use with MeGUI. I hope this solve all the problems.
# 5.1 Channels L,R,C,LFE,SL,SR -> stereo + LFE
function c6_stereo(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
lf = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
fl_sl = MixAudio(fl, sl, 0.2929, 0.2929)
fr_sr = MixAudio(fr, sr, 0.2929, 0.2929)
fc_lf = MixAudio(fc, lf, 0.2071, 0.2071)
l = MixAudio(fl_sl, fc_lf, 1.0, 1.0)
r = MixAudio(fr_sr, fc_lf, 1.0, 1.0)
return MergeChannels(l, r)
}
# 5 Channels L,R,C,SL,SR or L,R,LFE,SL,SR-> Stereo
function c5_stereo(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
fl_sl = MixAudio(fl, sl, 0.3694, 0.3694)
fr_sr = MixAudio(fr, sr, 0.3694, 0.3694)
l = MixAudio(fl_sl, fc, 1.0, 0.2612)
r = MixAudio(fr_sr, fc, 1.0, 0.2612)
return MergeChannels(l, r)
}
# 5 Channels L,R,C,LFE,S -> Stereo
function c52_stereo(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
lf = GetChannel(a, 4)
bc = GetChannel(a, 5)
fl_bc = MixAudio(fl, bc, 0.3205, 0.2265)
fr_bc = MixAudio(fr, bc, 0.3205, 0.2265)
fc_lf = MixAudio(fc, lf, 0.2265, 0.2265)
l = MixAudio(fl_bc, fc_lf, 1.0, 1.0)
r = MixAudio(fr_bc, fc_lf, 1.0, 1.0)
return MergeChannels(l, r)
}
# 4 Channels Quadro L,R,SL,SR -> Stereo
function c4_stereo(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
sl = GetChannel(a, 3)
sr = GetChannel(a, 4)
l = MixAudio(fl, sl, 0.5, 0.5)
r = MixAudio(fr, sr, 0.5, 0.5)
return MergeChannels(l, r)
}
# 4 Channels L,R,C,LFE or L,R,S,LFE or L,R,C,S -> Stereo
function c42_stereo(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
lf = GetChannel(a, 4)
fc_lf = MixAudio(fc, lf, 0.2929, 0.2929)
l = MixAudio(fl, fc_lf, 0.4142, 1.0)
r = MixAudio(fr, fc_lf, 0.4142, 1.0)
return MergeChannels(l, r)
}
# 3 Channels L,R,C or L,R,S or L,R,LFE -> Stereo
function c3_stereo(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
l = MixAudio(fl, fc, 0.5858, 0.4142)
r = MixAudio(fr, fc, 0.5858, 0.4142)
return MergeChannels(l, r)
}
# 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic
function c6_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
bc = MixAudio(sl, sr, 0.2265, 0.2265)
fl_fc = MixAudio(fl, fc, 0.3205, 0.2265)
fr_fc = MixAudio(fr, fc, 0.3205, 0.2265)
l = MixAudio(fl_fc, bc, 1.0, 1.0)
r = MixAudio(fr_fc, bc, 1.0, -1.0)
return MergeChannels(l, r)
}
# 5 Channels L,R,C,SL,SR -> Dolby ProLogic
function c5_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
bc = MixAudio(sl, sr, 0.2265, 0.2265)
fl_fc = MixAudio(fl, fc, 0.3205, 0.2265)
fr_fc = MixAudio(fr, fc, 0.3205, 0.2265)
l = MixAudio(fl_fc, bc, 1.0, 1.0)
r = MixAudio(fr_fc, bc, 1.0, -1.0)
return MergeChannels(l, r)
}
# 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic
function c52_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
bc = MixAudio(sl, sr, 0.2929, 0.2929)
l = MixAudio(fl, bc, 0.4142, 1.0)
r = MixAudio(fr, bc, 0.4142, -1.0)
return MergeChannels(l, r)
}
# 5 Channels L,R,C,LFE,S -> Dolby ProLogic
function c53_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
bc = GetChannel(a, 5)
fl_fc = MixAudio(fl, fc, 0.4142, 0.2929)
fr_fc = MixAudio(fr, fc, 0.4142, 0.2929)
l = MixAudio(fl_fc, bc, 1.0, 0.2929)
r = MixAudio(fr_fc, bc, 1.0, -0.2929)
return MergeChannels(l, r)
}
# 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic
function c4_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
sl = GetChannel(a, 3)
sr = GetChannel(a, 4)
bc = MixAudio(sl, sr, 0.2929, 0.2929)
l = MixAudio(fl, bc, 0.4142, 1.0)
r = MixAudio(fr, bc, 0.4142, -1.0)
return MergeChannels(l, r)
}
# 4 Channels L,R,LFE,S -> Dolby ProLogic
function c42_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
bc = GetChannel(a, 4)
l = MixAudio(fl, bc, 0.5858, 0.4142)
r = MixAudio(fr, bc, 0.5858, -0.4142)
return MergeChannels(l, r)
}
# 4 Channels L,R,C,S -> Dolby ProLogic
function c43_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
bc = GetChannel(a, 4)
fl_fc = MixAudio(fl, fc, 0.4142, 0.2929)
fr_fc = MixAudio(fr, fc, 0.4142, 0.2929)
l = MixAudio(fl_fc, bc, 1.0, 0.2929)
r = MixAudio(fr_fc, bc, 1.0, -0.2929)
return MergeChannels(l, r)
}
# 3 Channels L,R,S -> Dolby ProLogic
function c3_dpl(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
bc = GetChannel(a, 3)
l = MixAudio(fl, bc, 0.5858, 0.4142)
r = MixAudio(fr, bc, 0.5858, -0.4142)
return MergeChannels(l, r)
}
# 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic II
function c6_dpl2(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
ssl = MixAudio(sl, sr, 0.2818, 0.1627)
ssr = MixAudio(sl, sr, -0.1627, -0.2818)
fl_fc = MixAudio(fl, fc, 0.3254, 0.2301)
fr_fc = MixAudio(fr, fc, 0.3254, 0.2301)
l = MixAudio(fl_fc, ssl, 1.0, 1.0)
r = MixAudio(fr_fc, ssr, 1.0, 1.0)
return MergeChannels(l, r)
}
# 5 Channels L,R,C,SL,SR -> Dolby ProLogic II
function c5_dpl2(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
fc = GetChannel(a, 3)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
ssl = MixAudio(sl, sr, 0.2818, 0.1627)
ssr = MixAudio(sl, sr, -0.1627, -0.2818)
fl_fc = MixAudio(fl, fc, 0.3254, 0.2301)
fr_fc = MixAudio(fr, fc, 0.3254, 0.2301)
l = MixAudio(fl_fc, ssl, 1.0, 1.0)
r = MixAudio(fr_fc, ssr, 1.0, 1.0)
return MergeChannels(l, r)
}
# 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic II
function c52_dpl2(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
sl = GetChannel(a, 4)
sr = GetChannel(a, 5)
ssl = MixAudio(sl, sr, 0.3714, 0.2144)
ssr = MixAudio(sl, sr, -0.2144, -0.3714)
l = MixAudio(fl, ssl, 0.4142, 1.0)
r = MixAudio(fr, ssr, 0.4142, 1.0)
return MergeChannels(l, r)
}
# 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic II
function c4_dpl2(clip a)
{
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
sl = GetChannel(a, 3)
sr = GetChannel(a, 4)
ssl = MixAudio(sl, sr, 0.3714, 0.2144)
ssr = MixAudio(sl, sr, -0.2144, -0.3714)
l = MixAudio(fl, ssl, 0.4142, 1.0)
r = MixAudio(fr, ssr, 0.4142, 1.0)
return MergeChannels(l, r)
}

Zathor
4th December 2010, 12:09
Once again thank you very much for your great help. Your improvements are included in the new build 0.3.5.29.

doc_dvxm
4th December 2010, 16:22
Hi Guys. Same problem with me. Sorry for this long post...

I've converted 2.0 Ch AC3 to 2.0 Ch AAC.

The selected profile from meGUI is: Nero AAC: NDAAC-HE-64 Kbps.
Force Decoding via Dİrectshow: Checked
Apply Dynamic Tnage Compression: Checked
Output Channels: Keep original Channels.
Sample Rate: Keep original
Normilize Peaks to: 100
Constant Bitrate @ 64 Kbps
AAC Profile: HE-AAC.
Extension: MP4-AAC.

The Source is:


General
Complete name : D:\BluRay Disc Folder\2. Aliens 1986\Chapters & Subs\1_5_audio.ac3
Format : AC-3
Format/Info : Audio Coding 3
File size : 247 MiB
Duration : 2h 34mn
Overall bit rate : 224 Kbps

Audio
Format : AC-3
Format/Info : Audio Coding 3
Format profile : Dolby Digital
Mode extension : CM (complete main)
Duration : 2h 34mn
Bit rate mode : Constant
Bit rate : 224 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 247 MiB (100%)


Here is the MediaInfo from the final result:



General
Complete name : D:\BluRay Disc Folder\2. Aliens 1986\Chapters & Subs\1_5_audio_new.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42
File size : 71.5 MiB
Duration : 2h 34mn
Overall bit rate : 64.7 Kbps
Encoded date : UTC 2010-11-14 19:18:11
Tagged date : UTC 2010-11-14 19:23:21
Writing application : Nero AAC codec / 1.5.4.0
cdec : ndaudio 1.5.4.0 / -cbr 64000 -he

Audio
ID : 1
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 4
Format profile : LC
Format settings, SBR : Yes
Format settings, PS : No
Codec ID : 40
Duration : 2h 34mn
Bit rate mode : Variable
Bit rate : 63.9 Kbps
Maximum bit rate : 76.0 Kbps
Channel(s) : 3 channels
Channel positions : Front: L C R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 70.6 MiB (99%)
Encoded date : UTC 2010-11-14 19:18:11
Tagged date : UTC 2010-11-14 19:23:21



The log from meGUI is here:


-[Information] Log for job1 (audio, 1_5_audio.ac3 -> 1_5_audio_new.mp4)
--[Information] [14.11.2010 21:17:39] Started handling job
--[Information] [14.11.2010 21:17:39] Preprocessing
--[Information] Avisynth script
---[NoImage] DirectShowSource("D:\BluRay Disc Folder\2. Aliens 1986\Chapters & Sıbs\1_5_audio.ac3")
---[NoImage] EnsureVBRMP3Sync()
---[NoImage] Normalize()
---[NoImage] return last
--[Information] Commandline used: -ignorelength -he -cbr 64000 -if - -of "{0}"
--[Information] [14.11.2010 21:17:39] Encoding started
--[Information] [14.11.2010 21:17:39] Encode thread started
--[Information] [14.11.2010 21:17:39] Avisynth script environment opened
--[Information] [14.11.2010 21:17:41] Script loaded
--[Information] Output Decoder
---[Information] Channels: 3
---[Information] Bits per sample: 16
---[Information] Sample rate: 48000
--[Information] Commandline: D:\Encoder Folder\eac3to\neroAacEnc.exe -ignorelength -he -cbr 64000 -if - -of "D:\BluRay Disc Folder\2. Aliens 1986\Chapters & Sıbs\1_5_audio_new.mp4"
--[Information] [14.11.2010 21:17:41] Encoder process started
--[Information] Output from encoder via stderr
---[NoImage] *************************************************************
---[NoImage] * *
---[NoImage] * Nero AAC Encoder *
---[NoImage] * Copyright 2009 Nero AG *
---[NoImage] * All Rights Reserved Worldwide *
---[NoImage] * *
---[NoImage] * Package build date: Feb 18 2010 *
---[NoImage] * Package version: 1.5.4.0 *
---[NoImage] * *
---[NoImage] * See -help for a complete list of available parameters. *
---[NoImage] * *
---[NoImage] *************************************************************
--[Information] [14.11.2010 21:23:25] Postprocessing
---[Information] Deleting intermediate files
--[Information] [14.11.2010 21:23:25] Job completed
-[Information] Log for job2 (audio, 1_10_audio.ac3 -> 1_10_audio.mp4)
--[Information] [14.11.2010 21:23:25] Started handling job
--[Information] [14.11.2010 21:23:25] Preprocessing
--[Information] Avisynth script
---[NoImage] DirectShowSource("D:\BluRay Disc Folder\2. Aliens 1986\Chapters & Sıbs\1_10_audio.ac3")
---[NoImage] EnsureVBRMP3Sync()
---[NoImage] Normalize()
---[NoImage] return last
--[Information] Commandline used: -ignorelength -he -cbr 64000 -if - -of "{0}"
--[Information] [14.11.2010 21:23:25] Encoding started
--[Information] [14.11.2010 21:23:25] Encode thread started
--[Information] [14.11.2010 21:23:25] Avisynth script environment opened
--[Information] [14.11.2010 21:23:45] Script loaded
--[Information] Output Decoder
---[Information] Channels: 3
---[Information] Bits per sample: 16
---[Information] Sample rate: 48000
--[Information] Commandline: D:\Encoder Folder\eac3to\neroAacEnc.exe -ignorelength -he -cbr 64000 -if - -of "D:\BluRay Disc Folder\2. Aliens 1986\Chapters & Sıbs\1_10_audio.mp4"
--[Information] [14.11.2010 21:23:45] Encoder process started
--[Information] Output from encoder via stderr
---[NoImage] *************************************************************
---[NoImage] * *
---[NoImage] * Nero AAC Encoder *
---[NoImage] * Copyright 2009 Nero AG *
---[NoImage] * All Rights Reserved Worldwide *
---[NoImage] * *
---[NoImage] * Package build date: Feb 18 2010 *
---[NoImage] * Package version: 1.5.4.0 *
---[NoImage] * *
---[NoImage] * See -help for a complete list of available parameters. *
---[NoImage] * *
---[NoImage] *************************************************************
--[Information] [14.11.2010 21:29:26] Postprocessing
---[Information] Deleting intermediate files
--[Information] [14.11.2010 21:29:26] Job completed


Am I doing something wrong?

I've just saw the avs script given by tebasuna. I'll try with this script and I'll write again...

tebasuna51
4th December 2010, 23:26
...

Output Channels: Keep original Channels.

Am I doing something wrong?.
If you want downmix to stereo you must select a downmix function instead Keep original Channels.

For me this is also wrong:

Force Decoding via Dİrectshow: Checked
Apply Dynamic Range Compression: Checked

But is your choice.

doc_dvxm
5th December 2010, 00:48
I select Keep original channels, be'coz the source is also 2.0 channels.

Thanx for your suggestions tebasuna. I'll try to do it again...

tebasuna51
5th December 2010, 03:59
I select Keep original channels, be'coz the source is also 2.0 channels...
Sorry I don't see that.

Then uncheck Force Decoding via DirectShow and must work.

doc_dvxm
5th December 2010, 22:22
Thank you very much tebasuna...

Both methods -

1. given script and
2. Unchecking the Force Decoding via Directshow working.

Best Regards,

doc