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.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 30th July 2012, 10:35   #1  |  Link
gurusinghbrar
Registered User
 
Join Date: Jul 2012
Posts: 39
HELP: Convert Multichannel to Stereo via avs

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
gurusinghbrar is offline   Reply With Quote
Old 30th July 2012, 11:31   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,372
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)
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Old 30th July 2012, 11:45   #3  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 4,997
Wouldn't it be easier to just batch eac3to with "-down2" and avoid AviSynth and DirectShow altogether?
sneaker_ger is offline   Reply With Quote
Old 30th July 2012, 14:27   #4  |  Link
gurusinghbrar
Registered User
 
Join Date: Jul 2012
Posts: 39
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
gurusinghbrar is offline   Reply With Quote
Old 30th July 2012, 14:34   #5  |  Link
ramicio
Banned
 
Join Date: Mar 2004
Location: PA, US
Posts: 684
Downmixing is supposed to quiet each channel so as not to clip.
ramicio is offline   Reply With Quote
Old 31st July 2012, 06:46   #6  |  Link
gurusinghbrar
Registered User
 
Join Date: Jul 2012
Posts: 39
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
gurusinghbrar is offline   Reply With Quote
Old 31st July 2012, 09:51   #7  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,372
Quote:
Originally Posted by gurusinghbrar View Post
...
hey @sneaker_ger i already use ur method but when i use it -down2 it down the volume of tracks.
Use -down2 -normalize

Quote:
Originally Posted by gurusinghbrar View Post
...
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:

Quote:
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.
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.

Last edited by tebasuna51; 31st July 2012 at 10:05. Reason: add more info
tebasuna51 is offline   Reply With Quote
Old 31st July 2012, 22:38   #8  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by tebasuna51 View Post
For audio only is enough:
Code:
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()
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 1st August 2012, 14:42   #9  |  Link
gurusinghbrar
Registered User
 
Join Date: Jul 2012
Posts: 39
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
gurusinghbrar is offline   Reply With Quote
Old 1st August 2012, 17:28   #10  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,372
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)
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:11.


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