Log in

View Full Version : Audio downmix


gispos
23rd April 2023, 14:08
Can someone please write me some approximate correct lines for audio downmix to stereo for avisynth's audio mixer?

8 channel, 6 channel, 5 channel?, 4 channel, 3 channel?
I have this:

6 channel to 2:
flr = GetChannel(1, 2)
fcc = GetChannel(3, 3)
lrc = MixAudio(flr, fcc, 0.4, 0.4)
blr = GetChannel(5, 6)
MixAudio(lrc, blr, 1.0, 0.2)

4 channel to 2:
flr = GetChannel(1, 2)
blr = GetChannel(3, 4)
MixAudio(flr, blr, 0.5, 0.5)

manolito
23rd April 2023, 17:03
Here is the latest downmix script from AVStoDVD from 2019. It is based on Tebasuna`s script with a few minor additions. Download here:

https://files.videohelp.com/u/172211/A2D_Downmix.zip

AFAIK Tebasuna has newer versions of this script available, but this older one has always worked well...


Cheers
manolito

gispos
23rd April 2023, 20:11
Thanks manolito

StainlessS
24th April 2023, 16:33
This is what I usually use,

Favc.avsi

Function FAVCStereo(clip Video, clip Audio) {

Dubbed = Video

Chan0 = (HasAudio(Audio)==False) ? AudioDub(Video, BlankClip(Video, audio_rate=48000, stereo=true)) : nop()
Dubbed = (HasAudio(Audio)==False) ? Chan0 : Dubbed

Audio = (HasAudio(Audio)==True) ? ConvertAudioToFloat(Audio) : Audio

Chan1 = (AudioChannels(Audio)==1) ? Audiodub(Video, GetChannel(Audio, 1, 1)) : nop()
Dubbed = (AudioChannels(Audio)==1) ? Chan1 : Dubbed

Chan2 = (AudioChannels(Audio)==2) ? Audiodub(Video, Audio) : nop()
Dubbed = (AudioChannels(Audio)==2) ? Chan2 : Dubbed

FrontLeft = (AudioChannels(Audio)==3) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 2), 0.5, 0.5) : nop()
FrontRight = (AudioChannels(Audio)==3) ? MixAudio(GetChannel(Audio, 3), GetChannel(Audio, 2), 0.5, 0.5) : nop()
Chan3 = (AudioChannels(Audio)==3) ? Audiodub(Video, MergeChannels(FrontLeft, FrontRight)) : nop()
Dubbed = (AudioChannels(Audio)==3) ? Chan3 : Dubbed

TotalLeft = (AudioChannels(Audio)==4) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 3), 0.5, 0.5) : nop()
TotalRight = (AudioChannels(Audio)==4) ? MixAudio(GetChannel(Audio, 2), GetChannel(Audio, 4), 0.5, 0.5) : nop()
Chan4 = (AudioChannels(Audio)==4) ? Audiodub(Video, MergeChannels(TotalLeft, TotalRight)) : nop()
Dubbed = (AudioChannels(Audio)==4) ? Chan4 : Dubbed

FrontLeft = (AudioChannels(Audio)==5) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 2), 0.3694, 0.2612) : nop()
FrontRight = (AudioChannels(Audio)==5) ? MixAudio(GetChannel(Audio, 3), GetChannel(Audio, 2), 0.3694, 0.2612) : nop()
TotalLeft = (AudioChannels(Audio)==5) ? MixAudio(FrontLeft, GetChannel(Audio, 4), 1, 0.3694) : nop()
TotalRight = (AudioChannels(Audio)==5) ? MixAudio(FrontRight, GetChannel(Audio, 5), 1, 0.3694) : nop()
Chan5 = (AudioChannels(Audio)==5) ? Audiodub(Video, MergeChannels(TotalLeft, TotalRight)) : nop()
Dubbed = (AudioChannels(Audio)==5) ? Chan5 : Dubbed

BackLeft = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 4), GetChannel(Audio, 6), 0.2698, 0.2698) : nop()
BackRight = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 5), GetChannel(Audio, 6), 0.2698, 0.2698) : nop()
FrontLeft = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 2), 0.2698, 0.1906) : nop()
FrontRight = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 3), GetChannel(Audio, 2), 0.2698, 0.1906) : nop()
TotalLeft = (AudioChannels(Audio)>=6) ? MixAudio(FrontLeft, BackLeft, 1, 1) : nop()
TotalRight = (AudioChannels(Audio)>=6) ? MixAudio(FrontRight, BackRight, 1, 1) : nop()
Chan6 = (AudioChannels(Audio)>=6) ? Audiodub(Video, MergeChannels(TotalLeft, TotalRight)) : nop()
Dubbed = (AudioChannels(Audio)>=6) ? Chan6 : Dubbed


# Dubbed = (HasAudio(Audio)==True) ? Normalize(Dubbed) : Dubbed
# Dubbed = (HasAudio(Audio)==True) ? SSRC(Dubbed, 48000) : Dubbed
Dubbed = (HasAudio(Audio)==True) ? ConvertAudioTo16bit(Dubbed) : Dubbed

return(Dubbed)
}

Function FAVCStereoDSS(clip Video, clip Audio) {

Dubbed = Video

Chan0 = (HasAudio(Audio)==False) ? AudioDub(Video, BlankClip(Video, audio_rate=48000, stereo=true)) : nop()
Dubbed = (HasAudio(Audio)==False) ? Chan0 : Dubbed

Audio = (HasAudio(Audio)==True) ? ConvertAudioToFloat(Audio) : Audio

Chan1 = (AudioChannels(Audio)==1) ? Audiodub(Video, GetChannel(Audio, 1, 1)) : nop()
Dubbed = (AudioChannels(Audio)==1) ? Chan1 : Dubbed

Chan2 = (AudioChannels(Audio)==2) ? Audiodub(Video, Audio) : nop()
Dubbed = (AudioChannels(Audio)==2) ? Chan2 : Dubbed

FrontLeft = (AudioChannels(Audio)==3) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 3), 0.5, 0.5) : nop()
FrontRight = (AudioChannels(Audio)==3) ? MixAudio(GetChannel(Audio, 2), GetChannel(Audio, 3), 0.5, 0.5) : nop()
Chan3 = (AudioChannels(Audio)==3) ? Audiodub(Video, MergeChannels(FrontLeft, FrontRight)) : nop()
Dubbed = (AudioChannels(Audio)==3) ? Chan3 : Dubbed

TotalLeft = (AudioChannels(Audio)==4) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 3), 0.5, 0.5) : nop()
TotalRight = (AudioChannels(Audio)==4) ? MixAudio(GetChannel(Audio, 2), GetChannel(Audio, 4), 0.5, 0.5) : nop()
Chan4 = (AudioChannels(Audio)==4) ? Audiodub(Video, MergeChannels(TotalLeft, TotalRight)) : nop()
Dubbed = (AudioChannels(Audio)==4) ? Chan4 : Dubbed

FrontLeft = (AudioChannels(Audio)==5) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 3), 0.3694, 0.2612) : nop()
FrontRight = (AudioChannels(Audio)==5) ? MixAudio(GetChannel(Audio, 2), GetChannel(Audio, 3), 0.3694, 0.2612) : nop()
TotalLeft = (AudioChannels(Audio)==5) ? MixAudio(FrontLeft, GetChannel(Audio, 4), 1, 0.3694) : nop()
TotalRight = (AudioChannels(Audio)==5) ? MixAudio(FrontRight, GetChannel(Audio, 5), 1, 0.3694) : nop()
Chan5 = (AudioChannels(Audio)==5) ? Audiodub(Video, MergeChannels(TotalLeft, TotalRight)) : nop()
Dubbed = (AudioChannels(Audio)==5) ? Chan5 : Dubbed

BackLeft = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 5), GetChannel(Audio, 4), 0.2698, 0.2698) : nop()
BackRight = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 6), GetChannel(Audio, 4), 0.2698, 0.2698) : nop()
FrontLeft = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 3), 0.2698, 0.1906) : nop()
FrontRight = (AudioChannels(Audio)>=6) ? MixAudio(GetChannel(Audio, 2), GetChannel(Audio, 3), 0.2698, 0.1906) : nop()
TotalLeft = (AudioChannels(Audio)>=6) ? MixAudio(FrontLeft, BackLeft, 1, 1) : nop()
TotalRight = (AudioChannels(Audio)>=6) ? MixAudio(FrontRight, BackRight, 1, 1) : nop()
Chan6 = (AudioChannels(Audio)>=6) ? Audiodub(Video, MergeChannels(TotalLeft, TotalRight)) : nop()
Dubbed = (AudioChannels(Audio)>=6) ? Chan6 : Dubbed


# Dubbed = (HasAudio(Audio)==True) ? Normalize(Dubbed) : Dubbed
# Dubbed = (HasAudio(Audio)==True) ? SSRC(Dubbed, 48000) : Dubbed
Dubbed = (HasAudio(Audio)==True) ? ConvertAudioTo16bit(Dubbed) : Dubbed

return(Dubbed)
}

I think it came from on-site somewhere, dont know who wrote it.

EDIT: This seems to be first posting about Favc:- https://forum.doom9.org/showthread.php?p=1011126#post1011126

EDIT: And a partial script where I use it,

if(HasAudio) { # SampleRate > 0
RT_DebugF("Audio Channels = %d",AudioChannels)
# WARNING Channels = 0 Means MONO ???
if(G_CHANNELS == 0 && AudioChannels > 0) {
RT_DebugF("Killing Audio",name=myName)
DoLog(RT_String("Killaudio()"))
KillAudio()
} else if(G_CHANNELS == 1 && AudioChannels > 1) {
RT_DebugF("Converting To MONO",name=myName)
DoLog(RT_String("ConvertToMono()"))
ConvertToMono()
} else if(G_CHANNELS == 2 && AudioChannels ==1) {
RT_DebugF("Converting To DUEL Channel MONO",name=myName)
DoLog(RT_String("AudioDub(Last,MergeChannels(GetChannel(1),GetChannel(1))) # Matching to required output, 2 audio channels"))
AudioDub(Last,MergeChannels(GetChannel(1),GetChannel(1)))
} Else if (G_CHANNELS == 2 && AudioChannels != 2) {
RT_DebugF("Converting To Stereo",name=myName)
DoLog(RT_string("FAVCStereo(Last,Last) # Converting audio output to Stereo"))
FAVCStereo(Last,Last)
}
RT_DebugF("Channels = %d",AudioChannels)
if(HasAudio() && G_BITS != AudioBits) {
if(G_BITS==8) {
DoLog(RT_String("ConvertAudioTo8bit() # Matching to required AudioBits"))
ConvertAudioTo8bit()
} else if(G_BITS==16) {
DoLog(RT_String("ConvertAudioTo16bit() # Matching to required AudioBits"))
ConvertAudioTo16bit()
} else if(G_BITS==24) {
DoLog(RT_String("ConvertAudioTo24bit() # Matching to required AudioBits"))
ConvertAudioTo24bit()
} else if(G_BITS==32) {
DoLog(RT_String("ConvertAudioTo32bit() # Matching to required AudioBits"))
ConvertAudioTo32bit()
}
}
if(HasAudio() && G_SAMPLERATE != AudioRate) {
DoLog(RT_String("ResampleAudio(%d) # Match to required Audio SampleRate",G_SAMPLERATE))
ResampleAudio(G_SAMPLERATE)
}
if(HasAudio() && G_NORMALIZE && !IsSilent) {
DoLog(RT_String("Normalize(0.98)"))
Normalize(0.98)
RT_DebugF("NORMALIZING AUDIO",name=myName)
}
} Else {
RT_DebugF("Has No Audio",name=myName)
}

I usually only bother with stereo, and have had no problems that I'm aware of.

EDIT: It may have come from VideoHelp forum.

EDIT: Was added before Avs+ native logging thingy.

Function DoLog(string s) { G_LOGNAME!="" ? RT_WriteFile(G_LOGNAME,"%s",s,Append=True) : NOP }


EDIT: From Wiki, http://avisynth.nl/index.php/SSRC
Unlike ResampleAudio, SSRC doesn't work for arbitrary sample rate ratios. If it cannot handle resampling between the two sample rates, an error is raised.
IanB once said something like, "ResampleAudio was refactored and is now almost as good as SSRC()."
I dont bother with SSRC() due to above IanB remark, and avoid the occasional SSRC() problem. (I guess a first try/catch on SSRC() might be better)

gispos
25th April 2023, 19:42
Thanks to you too StainlessS. The things that manolito has posted meet my needs. Small and handy.

kedautinh12
26th April 2023, 01:51
Here i got from Megui
---[NoImage] c6_stereo(ConvertAudioToFloat(last))
---[NoImage] Normalize()
---[NoImage] return last
---[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> stereo + LFE
---[NoImage] function c6_stereo(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] lf = GetChannel(a, 4)
---[NoImage] sl = GetChannel(a, 5)
---[NoImage] sr = GetChannel(a, 6)
---[NoImage] fl_sl = MixAudio(fl, sl, 0.2929, 0.2929)
---[NoImage] fr_sr = MixAudio(fr, sr, 0.2929, 0.2929)
---[NoImage] fc_lf = MixAudio(fc, lf, 0.2071, 0.2071)
---[NoImage] l = MixAudio(fl_sl, fc_lf, 1.0, 1.0)
---[NoImage] r = MixAudio(fr_sr, fc_lf, 1.0, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,C,SL,SR or L,R,LFE,SL,SR-> Stereo
---[NoImage] function c5_stereo(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] sl = GetChannel(a, 4)
---[NoImage] sr = GetChannel(a, 5)
---[NoImage] fl_sl = MixAudio(fl, sl, 0.3694, 0.3694)
---[NoImage] fr_sr = MixAudio(fr, sr, 0.3694, 0.3694)
---[NoImage] l = MixAudio(fl_sl, fc, 1.0, 0.2612)
---[NoImage] r = MixAudio(fr_sr, fc, 1.0, 0.2612)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,C,LFE,S -> Stereo
---[NoImage] function c52_stereo(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] lf = GetChannel(a, 4)
---[NoImage] bc = GetChannel(a, 5)
---[NoImage] fl_bc = MixAudio(fl, bc, 0.3205, 0.2265)
---[NoImage] fr_bc = MixAudio(fr, bc, 0.3205, 0.2265)
---[NoImage] fc_lf = MixAudio(fc, lf, 0.2265, 0.2265)
---[NoImage] l = MixAudio(fl_bc, fc_lf, 1.0, 1.0)
---[NoImage] r = MixAudio(fr_bc, fc_lf, 1.0, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 4 Channels Quadro L,R,SL,SR -> Stereo
---[NoImage] function c4_stereo(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] sl = GetChannel(a, 3)
---[NoImage] sr = GetChannel(a, 4)
---[NoImage] l = MixAudio(fl, sl, 0.5, 0.5)
---[NoImage] r = MixAudio(fr, sr, 0.5, 0.5)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 4 Channels L,R,C,LFE or L,R,S,LFE or L,R,C,S -> Stereo
---[NoImage] function c42_stereo(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] lf = GetChannel(a, 4)
---[NoImage] fc_lf = MixAudio(fc, lf, 0.2929, 0.2929)
---[NoImage] l = MixAudio(fl, fc_lf, 0.4142, 1.0)
---[NoImage] r = MixAudio(fr, fc_lf, 0.4142, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 3 Channels L,R,C or L,R,S or L,R,LFE -> Stereo
---[NoImage] function c3_stereo(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] l = MixAudio(fl, fc, 0.5858, 0.4142)
---[NoImage] r = MixAudio(fr, fc, 0.5858, 0.4142)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic
---[NoImage] function c6_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] sl = GetChannel(a, 5)
---[NoImage] sr = GetChannel(a, 6)
---[NoImage] bc = MixAudio(sl, sr, 0.2265, 0.2265)
---[NoImage] fl_fc = MixAudio(fl, fc, 0.3205, 0.2265)
---[NoImage] fr_fc = MixAudio(fr, fc, 0.3205, 0.2265)
---[NoImage] l = MixAudio(fl_fc, bc, 1.0, 1.0)
---[NoImage] r = MixAudio(fr_fc, bc, 1.0, -1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,C,SL,SR -> Dolby ProLogic
---[NoImage] function c5_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] sl = GetChannel(a, 4)
---[NoImage] sr = GetChannel(a, 5)
---[NoImage] bc = MixAudio(sl, sr, 0.2265, 0.2265)
---[NoImage] fl_fc = MixAudio(fl, fc, 0.3205, 0.2265)
---[NoImage] fr_fc = MixAudio(fr, fc, 0.3205, 0.2265)
---[NoImage] l = MixAudio(fl_fc, bc, 1.0, 1.0)
---[NoImage] r = MixAudio(fr_fc, bc, 1.0, -1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic
---[NoImage] function c52_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] sl = GetChannel(a, 4)
---[NoImage] sr = GetChannel(a, 5)
---[NoImage] bc = MixAudio(sl, sr, 0.2929, 0.2929)
---[NoImage] l = MixAudio(fl, bc, 0.4142, 1.0)
---[NoImage] r = MixAudio(fr, bc, 0.4142, -1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,C,LFE,S -> Dolby ProLogic
---[NoImage] function c53_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] bc = GetChannel(a, 5)
---[NoImage] fl_fc = MixAudio(fl, fc, 0.4142, 0.2929)
---[NoImage] fr_fc = MixAudio(fr, fc, 0.4142, 0.2929)
---[NoImage] l = MixAudio(fl_fc, bc, 1.0, 0.2929)
---[NoImage] r = MixAudio(fr_fc, bc, 1.0, -0.2929)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic
---[NoImage] function c4_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] sl = GetChannel(a, 3)
---[NoImage] sr = GetChannel(a, 4)
---[NoImage] bc = MixAudio(sl, sr, 0.2929, 0.2929)
---[NoImage] l = MixAudio(fl, bc, 0.4142, 1.0)
---[NoImage] r = MixAudio(fr, bc, 0.4142, -1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 4 Channels L,R,LFE,S -> Dolby ProLogic
---[NoImage] function c42_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] bc = GetChannel(a, 4)
---[NoImage] l = MixAudio(fl, bc, 0.5858, 0.4142)
---[NoImage] r = MixAudio(fr, bc, 0.5858, -0.4142)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 4 Channels L,R,C,S -> Dolby ProLogic
---[NoImage] function c43_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] bc = GetChannel(a, 4)
---[NoImage] fl_fc = MixAudio(fl, fc, 0.4142, 0.2929)
---[NoImage] fr_fc = MixAudio(fr, fc, 0.4142, 0.2929)
---[NoImage] l = MixAudio(fl_fc, bc, 1.0, 0.2929)
---[NoImage] r = MixAudio(fr_fc, bc, 1.0, -0.2929)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 3 Channels L,R,S -> Dolby ProLogic
---[NoImage] function c3_dpl(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] bc = GetChannel(a, 3)
---[NoImage] l = MixAudio(fl, bc, 0.5858, 0.4142)
---[NoImage] r = MixAudio(fr, bc, 0.5858, -0.4142)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5.1 Channels L,R,C,LFE,SL,SR -> Dolby ProLogic II
---[NoImage] function c6_dpl2(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] sl = GetChannel(a, 5)
---[NoImage] sr = GetChannel(a, 6)
---[NoImage] ssl = MixAudio(sl, sr, 0.2818, 0.1627)
---[NoImage] ssr = MixAudio(sl, sr, -0.1627, -0.2818)
---[NoImage] fl_fc = MixAudio(fl, fc, 0.3254, 0.2301)
---[NoImage] fr_fc = MixAudio(fr, fc, 0.3254, 0.2301)
---[NoImage] l = MixAudio(fl_fc, ssl, 1.0, 1.0)
---[NoImage] r = MixAudio(fr_fc, ssr, 1.0, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,C,SL,SR -> Dolby ProLogic II
---[NoImage] function c5_dpl2(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] fc = GetChannel(a, 3)
---[NoImage] sl = GetChannel(a, 4)
---[NoImage] sr = GetChannel(a, 5)
---[NoImage] ssl = MixAudio(sl, sr, 0.2818, 0.1627)
---[NoImage] ssr = MixAudio(sl, sr, -0.1627, -0.2818)
---[NoImage] fl_fc = MixAudio(fl, fc, 0.3254, 0.2301)
---[NoImage] fr_fc = MixAudio(fr, fc, 0.3254, 0.2301)
---[NoImage] l = MixAudio(fl_fc, ssl, 1.0, 1.0)
---[NoImage] r = MixAudio(fr_fc, ssr, 1.0, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 5 Channels L,R,LFE,SL,SR -> Dolby ProLogic II
---[NoImage] function c52_dpl2(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] sl = GetChannel(a, 4)
---[NoImage] sr = GetChannel(a, 5)
---[NoImage] ssl = MixAudio(sl, sr, 0.3714, 0.2144)
---[NoImage] ssr = MixAudio(sl, sr, -0.2144, -0.3714)
---[NoImage] l = MixAudio(fl, ssl, 0.4142, 1.0)
---[NoImage] r = MixAudio(fr, ssr, 0.4142, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }
---[NoImage] # 4 Channels Quadro L,R,SL,SR -> Dolby ProLogic II
---[NoImage] function c4_dpl2(clip a)
---[NoImage] {
---[NoImage] fl = GetChannel(a, 1)
---[NoImage] fr = GetChannel(a, 2)
---[NoImage] sl = GetChannel(a, 3)
---[NoImage] sr = GetChannel(a, 4)
---[NoImage] ssl = MixAudio(sl, sr, 0.3714, 0.2144)
---[NoImage] ssr = MixAudio(sl, sr, -0.2144, -0.3714)
---[NoImage] l = MixAudio(fl, ssl, 0.4142, 1.0)
---[NoImage] r = MixAudio(fr, ssr, 0.4142, 1.0)
---[NoImage] return MergeChannels(l, r)
---[NoImage] }

StainlessS
26th April 2023, 02:09
Thanks to you too kedautinh12. The things that manolito has posted meet his needs. Small and handy. :)

coolgit
27th April 2023, 17:15
Why not just use Audacity, its free?

StainlessS
27th April 2023, 17:22
Why not just use Audacity, its free?
Methinks gispos intends to embed script function into AvsPMod.

richardpl
27th April 2023, 17:52
Why not just use Audacity, its free?

Not at all, full of adware and spyware. No thanks.

PoeBear
29th April 2023, 12:35
Not at all, full of adware and spyware. No thanks.

Lol, there are no ads in Audacity. And the only "spyware", is the check for updates feature (https://www.audacityteam.org/about/desktop-privacy-notice/), which you can literally disable on first run

StainlessS
29th April 2023, 18:18
I've never seen any ads in Audacity, maybe you downloaded modded ver$ from bad (non author) site.

writemaster
29th April 2023, 23:02
Do you also have a solution to make DD-EX audio with GetChannel?

gispos
30th April 2023, 13:50
I have a video with 8 channel audio and AvsPmod as well as VDub2 play channels that are firstly wrong and secondly not even selectable in PotPlayer.

I tried all indexes in LWLibavAudioSource, no index gives the right audio that the PotPlayer plays without any problems.

Enlighten me...

manolito
30th April 2023, 15:47
Can you upload a short sample?

gispos
30th April 2023, 18:33
Can you upload a short sample?
That is typical once again.
I tried two editing programs and MkvToolnix. After that I could play the clips with AvsPmod.

Apparently the video is not compliant enough and PotPlayer can handle it better.

But where does the channel come from that I can't select in PotPlayer but VDub2 and AvsPmod play.

Doesn't matter now, I will remux the video.

Edit:
What amazes me, I can play the video without audio dropouts with 'Resize Filter;Prefetch(1), VDub2 doesn't manage that without jerking.
Normally VDub2 is faster with 4K videos than AvsPmod.
Wrong world.:)

kedautinh12
30th April 2023, 18:38
Hi @gispos, can AVSPmod only encode audio without video?? If had, how to do that?

gispos
30th April 2023, 18:49
No, and I don't think that will come from my side. But never say never.

kedautinh12
1st May 2023, 05:21
Ok, Megui have that, i still use Megui :D

gispos
1st May 2023, 10:07
Then all is well. You are like a flag in the wind...

coolgit
2nd May 2023, 07:37
Not at all, full of adware and spyware. No thanks.

Nope.

richardpl
2nd May 2023, 09:20
Nope.

Citation needed, AFAIK they hide it very well, by removing any issues that try to point to spyware code.

coolgit
2nd May 2023, 11:22
Citation needed, AFAIK they hide it very well, by removing any issues that try to point to spyware code.

Uncheck auto update.

If you are paranoid then...
Block audacity using internet using firewall.

PoeBear
2nd May 2023, 21:20
Citation needed, AFAIK they hide it very well, by removing any issues that try to point to spyware code.

Lol, you're the one making baseless claims, so you're the one that needs the citation(s)

It's open source, so if it exists it will be in the code, no need to look at any open issues. It's hard to hide in the open: https://github.com/audacity/audacity/commits/master

StainlessS
3rd May 2023, 00:06
I gotto go with PoeBear,
I aint not never. not never, had probs with Audacity, and for you to say that you have seems a wee bit , '''''audacious'''''.

isidroco
8th March 2025, 06:05
[QUOTE=StainlessS;1986184]This is what I usually use,
...[/QUOTE

Rewrote same script for aviSynth+ a lot shorter and easier to follow, taking advantage of new IF blocks. If second clip (Audio) not present will use audio of first (Video) clip. Will optionally normalize if NormalizeA value is present and between 0.01 and 1.

Function FAVCStereo( clip Video, clip "Audio", float "NormalizeA" ) {

Audio = default( Audio, Video )
NormalizeA = default( NormalizeA, 0.0 )

if ( !HasAudio( Audio) ) { #no audio, return silent stereo
Dubbed= AudiodubEx( Video, BlankClip( Video, audio_rate= 48000, channels= 2) )
NormalizeA= 0.0
}
if ( AudioChannels( Audio)==1 ) {
Dubbed= AudiodubEx( Video, GetChannel( Audio, 1, 1) )
}
if ( AudioChannels( Audio)==2 ) {
Dubbed= AudiodubEx( Video, Audio)
}

Audio= ConvertAudioToFloat( killVideo( Audio) )
if ( AudioChannels( Audio)==3 ) {
FrontLeft = MixAudio( GetChannel( Audio, 1), GetChannel( Audio, 2), 0.5, 0.5 )
FrontRight = MixAudio( GetChannel( Audio, 3), GetChannel( Audio, 2), 0.5, 0.5 )
Dubbed= AudiodubEx( Video, MergeChannels( FrontLeft, FrontRight) )
}
if ( AudioChannels( Audio)==4 ) {
TotalLeft= MixAudio( GetChannel( Audio, 1), GetChannel( Audio, 3), 0.5, 0.5 )
TotalRight= MixAudio( GetChannel( Audio, 2), GetChannel( Audio, 4), 0.5, 0.5 )
Dubbed= AudiodubEx( Video, MergeChannels( TotalLeft, TotalRight) )
}
if ( AudioChannels( Audio)==5 ) {
FrontLeft= MixAudio( GetChannel( Audio, 1), GetChannel( Audio, 2), 0.3694, 0.2612 )
FrontRight= MixAudio( GetChannel( Audio, 3), GetChannel( Audio, 2), 0.3694, 0.2612 )
TotalLeft= MixAudio( FrontLeft, GetChannel( Audio, 4), 1, 0.3694 )
TotalRight= MixAudio( FrontRight, GetChannel( Audio, 5), 1, 0.3694 )
Dubbed= AudiodubEx( Video, MergeChannels( TotalLeft, TotalRight) )
}
if ( AudioChannels( Audio)>=6 ) {
BackLeft= MixAudio(GetChannel(Audio, 4), GetChannel(Audio, 6), 0.2698, 0.2698)
BackRight= MixAudio(GetChannel(Audio, 5), GetChannel(Audio, 6), 0.2698, 0.2698)
FrontLeft= MixAudio(GetChannel(Audio, 1), GetChannel(Audio, 2), 0.2698, 0.1906)
FrontRight= MixAudio(GetChannel(Audio, 3), GetChannel(Audio, 2), 0.2698, 0.1906)
TotalLeft= MixAudio(FrontLeft, BackLeft, 1, 1)
TotalRight= MixAudio(FrontRight, BackRight, 1, 1)
Dubbed= AudiodubEx(Video, MergeChannels(TotalLeft, TotalRight))
}

if ( 0.01 < NormalizeA <= 1.0001 ) {
Dubbed= ConvertAudioToFloat( Dubbed )
Dubbed = Normalize(Dubbed, NormalizeA )
}
# Dubbed = SSRC(Dubbed, 48000)
Dubbed = ConvertAudioTo16bit(Dubbed)

return( Dubbed)
}

StainlessS
8th March 2025, 11:39
Rewrote same script for aviSynth+ a lot shorter
I may have to use eg v2.58 sometimes, so I'll stick to the original script.
But thanx for posting.

isidroco
8th March 2025, 16:15
I may have to use eg v2.58 sometimes, so I'll stick to the original script.
But thanx for posting.
Thanks, you may want to add the optional parameters though. It's probably faster, but it's true that it won't work on old avisynth. Just added a small modification to allow no float<>16b conversion if not necessary.