pvann
28th September 2005, 23:29
Is there a way to access variables generated within ScriptClip in avisynth code outside ScriptClip?
To illustrate my question, in the sample script below, I use ScriptClip’s internal functions to put a value in the variable diffY and display that on the clip (using SubTitle() within ScriptClip), but I when I try to access diffY outside ScriptClip (the call to SubTitle() in line 6), it doesn’t show the same value.
A sample frame will have 0.123 in the centre of the frame (ie diffY defined in Line 1) and say 15.32 at the top of the frame (ie diffY from ScriptClip) – as I move from frame to frame, the 15.32 will change and the 0.123 will be constant.
global diffY = 0.123
clip = AVISource("C:C deshaker.avi")
clip = converttoYV12(clip)
clipProc = ScriptClip(clip,"global diffY = YDifferenceToNext()+YDifferenceFromPrevious()"
chr(13)+ "SubTitle(Clip, String(DiffY), align=8)") #put diffY from ScriptClip at top of clip
clipProc = SubTitle(ClipProc, string(diffY), align=5) #put diffY from AVISynth script at centre of clip
return clipProc
The reason I want to do this is to clean some old VHS home video using the overlay() function to blend the results of different smoothing/cleaning filters depending on the value of the variable diffY. I can code all of this in ScriptClip, but it is “neater” to do this outside ScriptClip! My initial results show smoother results than say that produced by QMF where they switch between two or three filters depending on the motion differences. If only I could pass “ScriptClip variables” outside ScriptClip. :confused:
Peter
To illustrate my question, in the sample script below, I use ScriptClip’s internal functions to put a value in the variable diffY and display that on the clip (using SubTitle() within ScriptClip), but I when I try to access diffY outside ScriptClip (the call to SubTitle() in line 6), it doesn’t show the same value.
A sample frame will have 0.123 in the centre of the frame (ie diffY defined in Line 1) and say 15.32 at the top of the frame (ie diffY from ScriptClip) – as I move from frame to frame, the 15.32 will change and the 0.123 will be constant.
global diffY = 0.123
clip = AVISource("C:C deshaker.avi")
clip = converttoYV12(clip)
clipProc = ScriptClip(clip,"global diffY = YDifferenceToNext()+YDifferenceFromPrevious()"
chr(13)+ "SubTitle(Clip, String(DiffY), align=8)") #put diffY from ScriptClip at top of clip
clipProc = SubTitle(ClipProc, string(diffY), align=5) #put diffY from AVISynth script at centre of clip
return clipProc
The reason I want to do this is to clean some old VHS home video using the overlay() function to blend the results of different smoothing/cleaning filters depending on the value of the variable diffY. I can code all of this in ScriptClip, but it is “neater” to do this outside ScriptClip! My initial results show smoother results than say that produced by QMF where they switch between two or three filters depending on the motion differences. If only I could pass “ScriptClip variables” outside ScriptClip. :confused:
Peter