View Full Version : HELP: Convert Multichannel to Stereo via avs
gurusinghbrar
30th July 2012, 10:35
hi,,
there is any script for audio Decoding like.
1. scirpt check wheather audio is stereo(2ch) or multichannel 6ch or 7ch
2. if multichannel found then it convert or downmix multichannel audio to stereo
3. or if input audio is strereo then decode this audio via DirectShowSource.
means all in one convert via avs script.
i want to use this script in batch audio convert method .... :)
plz help..
thank
tebasuna51
30th July 2012, 11:31
If you want use DirectShowSource, not always the best method to decode, you don't need check if an audio is stereo or multichannel.
You need only configure your DirectShow system to output stereo and be sure you have all the needed DS filters installed with the desired priority.
I recommend you install ffdshow (or last version of Ac3Filter 2.5b, now with the bug decoding DTS corrected) and configure the mixer option to output stereo.
You can also use a Custom Matrix to select the your desired downmix method (use always a Normalized matrix).
Don't use the 'on the fly' Normalize (in the Volume option), let Avisynth do the 2 pass Normalize:
DirectShowSource("your audio input")
Normalize(0.98)
or your desired value to normalize (max, and default, 1.0)
sneaker_ger
30th July 2012, 11:45
Wouldn't it be easier to just batch eac3to with "-down2" and avoid AviSynth and DirectShow altogether?
gurusinghbrar
30th July 2012, 14:27
thank's for fast rply...
hey @sneaker_ger i already use ur method but when i use it -down2 it down the volume of tracks.
and @tebasuna51 do u hav any script to make veriable like ( audio=DirectShowSource("....ac3") ) and compare it with ur funtion and get output.
function Dmix3Stereo(clip a) # 3 Channels L,R,C or L,R,S
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
return MixAudio(flr, fcc, 0.5858, 0.4142)
}
function Dmix3Dpl(clip a) # 3 Channels only L,R,S
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = Amplify(sl, -1.0)
blr = MergeChannels(sl, sr)
return MixAudio(flr, blr, 0.5858, 0.4142)
}
function Dmix4qStereo(clip a) # 4 Channels Quadro L,R,SL,SR
{
flr = GetChannel(a, 1, 2)
blr = GetChannel(a, 3, 4)
return MixAudio(flr, blr, 0.5, 0.5)
}
function Dmix4qDpl(clip a) # 4 Channels Quadro L,R,SL,SR
{
flr = GetChannel(a, 1, 2)
bl = GetChannel(a, 3)
br = GetChannel(a, 4)
sl = MixAudio(bl, br, 0.2929, 0.2929)
sr = MixAudio(bl, br, -0.2929, -0.2929)
blr = MergeChannels(sl, sr)
return MixAudio(flr, blr, 0.4142, 1.0)
}
thnkx
ramicio
30th July 2012, 14:34
Downmixing is supposed to quiet each channel so as not to clip.
gurusinghbrar
31st July 2012, 06:46
ok,,
i use ASX Gui and this application use script for audio conversion. it use "Downmix.avs" file to get input audio as variable and compare it with downmix.avs function's file. and get out put
but i want only audio output with this file. hey any body please change or make the changes in file for audio only.
1. Script use in Audio.avs
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Import("C:\Documents and Settings\Administrator\Desktop\d\tools\Downmix.avs")
LoadPlugin("C:\Documents and Settings\Administrator\Desktop\d\tools\BassAudio.dll")
Loadplugin("C:\Documents and Settings\Administrator\Desktop\d\tools\ffms2.dll")
video=ffvideosource("C:\Documents and Settings\Administrator\Desktop\MUxer\Cocktail.mp4")
audio=directshowsource("C:\Documents and Settings\Administrator\Desktop\MUxer\Cocktail.mp4", fps=25, seekzero=true)
audio = (audio.AudioChannels>2) ? DownMix(audio, audio.AudioChannels) : audio
audio = audio.Normalize()
AudioDub(video,audio)
----------------------------------------------------------------------------------
2. Downmix.avs file content is..
--------------------------------
function Downmix6(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2646, 0.1870)
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.1870)
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2291, 0.1323)
sr = MixAudio(bl, br, -0.1323, -0.2291)
blr = MergeChannels(sl, sr)
MixAudio(lrc, blr, 1.0, 1.0)
}
function Downmix5(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
bl = GetChannel(a, 4)
br = GetChannel(a, 5)
sl = MixAudio(bl, br, 0.2818, 0.1627)
sr = MixAudio(bl, br, -0.1627, -0.2818)
blr = MergeChannels(sl, sr)
MixAudio(lrc, blr, 1.0, 1.0)
}
function Downmix4(clip a)
{
flr = GetChannel(a, 1, 2)
bl = GetChannel(a, 3)
br = GetChannel(a, 4)
sl = MixAudio(bl, br, 0.3714, 0.2144)
sr = MixAudio(bl, br, -0.2144, -0.3714)
blr = MergeChannels(sl, sr)
MixAudio(flr, blr, 0.4142, 1.0)
}
function Downmix3(clip a)
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = Amplify(sl, -1.0)
blr = MergeChannels(sl, sr)
MixAudio(flr, blr, 0.5858, 0.4142)
}
function DownMix(clip a, int c)
{
a
(c>=6) ? Downmix6(a) : Last
(c==5) ? Downmix5(a) : Last
(c==4) ? Downmix4(a) : Last
(c==3) ? Downmix3(a) : Last
}
-----------------------------------
or please any body make both file or script in one file, so i could use that file for batch converting.
thanks
tebasuna51
31st July 2012, 09:51
...
hey @sneaker_ger i already use ur method but when i use it -down2 it down the volume of tracks.
Use -down2 -normalize
...
but i want only audio output with this file. hey any body please change or make the changes in file for audio only.
For audio only is enough:
Import("C:\Documents and Settings\Administrator\Desktop\d\tools\Downmix.avs")
audio=directshowsource("C:\Documents and Settings\Administrator\Desktop\MUxer\Cocktail.mp4")
audio = (audio.AudioChannels>2) ? DownMix(audio, audio.AudioChannels) : audio
audio = audio.Normalize()
But remember, you must have configured your DirectShow system to output the same number of channels than input source.
EDIT:
Warning, the downmix avs functions don't work correctly for all channels config.
Inside AviSynth we don't know the ChannelMask audio property and we can't select a proper downmix.
The DirectShow method sugested in my first post is a best option.
Gavino
31st July 2012, 22:38
For audio only is enough:
Import("C:\Documents and Settings\Administrator\Desktop\d\tools\Downmix.avs")
audio=directshowsource("C:\Documents and Settings\Administrator\Desktop\MUxer\Cocktail.mp4")
audio = (audio.AudioChannels>2) ? DownMix(audio, audio.AudioChannels) : audio
audio = audio.Normalize()
You can't end a script with an assignment.
Either add a further line:
return audio
Or replace the last line with:
return audio.Normalize()
gurusinghbrar
1st August 2012, 14:42
ok,, can anybody tell me how to find the correct left and right channel for 2ch stereo audio from ac3 6ch audio file,, or set any setting in ac3 filter to correct channel output..
thanx
tebasuna51
1st August 2012, 17:28
This is a Mixing Matrix to downmix 5.1 to stereo Dolby Prologic II.
Note:
There are coeficients for Side and Back channels because both are valid for 5.1. Of course only one pair is present at the same source. There are both only for 7.1
EDIT: Remember use:
DirectShowSource("your audio input")
Normalize(0.98)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.