Log in

View Full Version : global variable not working properly


rig99
25th February 2007, 20:14
Here is my avisynth script that is supposed to convert to NTSC if not already NTSC and is supposed to convert 6 channel to stereo (thank you tebasuna51!) if not already stereo. The problem is with the subinfo variable. At the end it always displays "unchanged subinfo" for my subtitle.

wicker_man.avi is a NTSC video with stereo audio in case you need to know.


global subinfo = "unchanged subinfo"
myclip = AVISource("C:\shows\wicker_man.avi")
#myclip=AssumeFPS(myclip ,23.976,sync_audio=true)
myclip = LanczosResize(myclip,688,336)
myclip = AddBorders(myclip,16,72,16,72)

function ToNTSC(clip a)
{
a = (Framerate(a)==25) ? Eval("""
subinfo = subinfo + " To 23.976"
AssumeFPS(a,23.976,sync_audio=true)
return last
""") : Eval("""
subinfo = subinfo + " Already 23.976"
return a
""")
return a
}

function ToStereo(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
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)
subinfo = subinfo + " To Stereo"
return last
}

function original(clip a)
{
subinfo = subinfo + " Orig. Audio"
return a
}

myclip = ToNTSC(myclip)
myclip = (Audiochannels(myclip)==6) ? ToStereo(myclip) : original(myclip)
return subtitle(myclip,subinfo)


If there is anything else wrong with this please tell me. Thanks.

Didée
25th February 2007, 21:00
When trying to manipulate a global variable, you have to specify "global" again. i.e. within your functions, you have to write

global subinfo = subinfo + {string}

Accordingly, for doing a re-assignment, you'd have to write

global subinfo = {new_value}