Log in

View Full Version : Need help with ConditionalFilter, ScriptClip, FrameEvaluate...


SoonUDie
15th December 2003, 09:54
Hey all!

My problem is this: I would like to use one of the stated functions above to store a non-clip value in a global variable. I've read everything I could find on this at Avisynth.org and here through searching, but for some reason I just can't get what I'm doing to work.

Here's an example of one way I tried to go about it with ConditionalFilter:

In psuedo-code:

function Main()
{
ConditionalFilter(vid1, vid1, vid1, "myFunction(luma(vid1) == luma(vid2))", "equals", "true")

return myVar
}

function myFunction(bool "test")\
{
global myVar = test
return test
}


The result of this script is that I get an avisynth error saying "I don't know what myVar means". But if I define myVar before the conditional filter, it just returns that instead of what myVar should be after the ConditionalFilter.

I also tried tying a function in to one of the returned sources, like

ConditionalFilter(vid1, myFunction2(), vid1...)

where myFunction2 sets a variable and returns a clip. Unfortunately, it seems that ConditionalFilter evaluates both results before the condition is checked, meaning that myFunction2() is activated even when the conditional is false.

I think this kind of thing should be easy to do in ScriptClip or FrameEvaluate, but I have no idea how to do it. This is kind of driving me nuts here. Please help me!

Thank you :)

sh0dan
15th December 2003, 10:53
Could you post a more "complete" script, and maybe describe what you are trying to do.

A basic thing you are missing is that the ONLY things that are updated on a per frame basis are things put into ConditionalFilter/FrameEvaluate/Scriptclip. 'return MyVar' is not updated after the script is created. Furthermore the conditionalfilter is never tun, since you need to pull frames through it, otherwise it is simply ignored. (you never use the result from conditionalfilter for anything).

SoonUDie
15th December 2003, 13:42
Thanks for the response sh0dan! I know you are responsible for these functions, so thanks :)

As per cF never being run, I've tried initiating a variable using conditionalFilter, but as you already know that alone won't get me where I want to be.

What I would like to do is create a function that will take two clips as input, compare them using some logic that involves functions like YDifferenceFromPrevious(), and then return the result of that operation (on a per-frame basis).

In psuedo-code, something like

function compare2(clip vid1, clip vid2)
{
global v1 = vid1
global v2 = vid2

return (logical statement comparing v1 and v2 using YDifferenceFromPrevious, output is boolean)
}

That's as simple as I can make it. I don't think I really need to post my full code, as there's not much more than what I've already posted except for the actual logical comparison itself (which I know works, using the show=true option on conditionalfilter and outputting the result).

If you can just show me a simple example of how to do something like the above pseudo-code, it would be quite easy for me to adapt my own code for it.

Thanks sh0dan! :)

SoonUDie
20th December 2003, 16:57
^ bump. I still need help :p

Wilbert
20th December 2003, 18:59
I suggest you look at the examples on this page:

http://www.avisynth.org/index.php?page=ConditionalFilter

1) ConditionalFilter returns a clip and not a boolean.

2) You should use FrameEvaluate for assigning variables (your booleans).