PDA

View Full Version : Why won't this work? I need some help with "FrameEvaluate"


Dinominant
9th November 2003, 20:24
Here is my script:


c = InputFile
ConvertToRGB(c)
AssumeTFF(c)
SeparateFields(c)
c1 = SelectEvery(c, 2, -1)
c2 = SelectEvery(c, 2, 0)
FrameEvaluate(c2, "ThisVariableWontWork = RGBDifference(c2, c1)")
Subtitle(String(ThisVariableWontWork))


When I am using FrameEvaluate, I wan't to set the RGBDifference of c2 and c1 to the variable "ThisVariableWontWork", so I can use the variable in my subtitle (or anything else). This isn't my entire script, but I choped the parts that matter out to make posting simpler, and tested it to make shure that it is working the way I don't want it to ;). I have done some searches on FrameEvaluate, and the best I came up with were complicated examples that I have no hope of understanding :P. So can sombody help me with this?

Thanks

sh0dan
9th November 2003, 21:06
Add "global ThisVariableWontWork = 0" at the top of the script to add the variable to the global scope and initialize it.

Dinominant
9th November 2003, 21:56
Yay, it worked! Except now I'm having another problem:

InputFile = SeparateFields(AssumeTFF(ConvertToRGB(AviSource("I:\DNA\New Folder\NTSC D2V_d2v-vfapi.avi"))))
Global WorkingVariable = 0
c1 = SelectEvery(InputFile, 2, -1)
c2 = SelectEvery(InputFile, 2, 0)
FrameEvaluate(c2, "WorkingVariable = RGBDifference(c2, c1)")
c2
Subtitle(String(WorkingVariable))

I want to see c2 in VirtualDub, with the RGBDiffernece of c2 and c1 as a subtitle using the WorkingVariable. This script works great except that the subtitle is always "0". More help??

c2 is the Current Top Field of InputFile
c1 is the Prevoius Bottom Filed of InputFile

That was a really fast reply, thanks for all of the help!:)

Didée
10th November 2003, 09:42
Dinominant,

it is like that:

the conditionals "ConditionalFilter", "ScriptClip" and "FrameEvaluate" are executed and evaluated on each and every frame as AviSynth walks through the clip.
Everything outside these conditionals is parsed and evaluated only once, on initialisation of the script.
Therefore, your variable "WorkingVariable" is correctly computed on every single frame -- but the "subtitle" you're using is *outside* the conditional environment, thus it gets evaluated only once (at frame 0, before stepping over it), and at this point the conditional computing was not executed even once.

To get what you want, it has to look like that:
InputFile = SeparateFields(AssumeTFF(ConvertToRGB(AviSource("I:\DNA\New Folder\NTSC D2V_d2v-vfapi.avi"))))
Global WorkingVariable = 0
c1 = SelectEvery(InputFile, 2, -1)
c2 = SelectEvery(InputFile, 2, 0)
x2=ScriptClip(c2, c2.subtitle(string(WorkingVariable))
x1=FrameEvaluate(x2, "WorkingVariable = RGBDifference(c2, c1)")
x1

The conditional part could have been done in only one line easily, but I wanted to demonstrate another "behaviour" of the conditional environment:
if you're going to use several conditional commands that are refering to each other, than you must build the chain from bottom to top, each line refering to the line above itself.

Hope I was clear enough

- Didée