Avisynth: Question on conditional operator
@sh0dan,
I have a question, related to the "false" condition on the "?" operator. If I have a function like this: ScriptClip("nf > scd_trigger ? asharp( -2,0) : asharp(0,0) ) I am forced to use some valid function on the false part, so it returns a valid "clip". I can't use something like this: ScriptClip("nf > scd_trigger ? asharp( -2,0) : nop() ) which is what I really want to do. That is, in this case, I don't want to return anything on the false condition because "asharp" is already applied on a previous function call before that line. So really I am using asharp(0,0) as a dummy call, but I assume there's some speed penalty because it's actually calling the function asharp instead of calling a null (nop) function. Is there a way around this, or some function I can call instead of nop() that doesn't cause a performance hit, and just returns nothing :?: -kwag |
2 ideas?
What about trying to call the clip itself "nf" as the false condition? Instead of the false statement being a valid function maybe it could be the unmodified starting clip variable "nf".
Or... you might be able to rearrange the logic. Instead of having the ScriptClip statement carrying the false condition you could write the statement such that the positive was something like: ScriptClip(nf, "asharp(-2,0)). The idea would be to bypass the limitation of how the script is written so that you COULD use nop() as the false condition? The entire ScriptClip function would be the positive and nop() would be the negative. ConditionalFilter might work. (I wish I was fluent enough with the Avisynth scripting to write a complete example :oops: ) Using this syntax (from the Avisynth.org site): ConditionalFilter(clip testclip, clip source1, clip source2, string filter, string operator, string value, [bool show]) It appears you could conditionally apply the asharp(-2,0) on positive and nop() on negative? Grantman |
Re: 2 ideas?
Quote:
ScriptClip("nf > scd_trigger ? asharp( -2,0) : nop() ") But it doesn't work, because on false conditions, nop() doesn't return a valid clip and issues an AviSynth error. -kwag |
Use "return last" instead of nop()
Anyway - unless you are modifying parameters on every frame (which you are not doing in this case), you should use ConditionalFilter - it is much faster than ScriptClip - and more stable. |
Thanks sh0dan, that's exactly the thing I was looking for :)
The script now reads: ScriptClip("nf > scd_trigger ? asharp( -2,0) : last ") And works like a charm ;) -kwag |
Fast solution:
sharp = asharp(-2,0) conditionalfilter(last,sharp,last, "nf",">", "scd_trigger") |
Quote:
Thanks sh0dan :D Updating script in a few moments :!: -kwag |
When I load a script with this new condionalfilter I'm getting an error in this line:
Quote:
Quote:
Anerboda |
Just looked at the script - I'm sorry, but it's wrong (it even surprises me it works ;) )
Anyway - sharp is a variable that gets assigned a clip, using the video at the current position. So you must keep the "sharp = " and conditional filter at the same place. Edit: Oh - you got the error message now ;) 1) Place "sharp = " right before the Conditionalfilter. The full syntax (without implicit last) is: Code:
sharp = asharp(last,-2,0) # Sharpen level on scene changes. 2) To optimize the first "scriptclip" away, try: Code:
input = last |
When I put these two lines together it works
Quote:
Quote:
Anerboda |
Yes - your filter should now be as before. Conditional filter is faster for choosing between two sources, because the filters themselves does not have to be created for each frame - as scriptclip. It also has the "show" parameter which helps debugging a lot.
This should also avoid potential memory leak explosion in buggy plugins. PS. I edited the post above. |
Thanks sh0dan,
I'll settle for conditionalfilter( last, asharp(-2,0), last, "nf", ">", "scd_trigger" ) just for user's simplicity :wink: I know, I know, hard coded variables :x, but if the script starts to grow, then we'll all dress it up :D -kwag |
@ Kwag..
I can't seem to locate this script.. or latest for that matter :( I want to utilize the latest changes and such, but blind. Is it possible to move this particular " Motion Adative xxx " script to the top or make it sticky or something - please ? Or am I loosing it. Thanks a bunch whatever the outcome. -vhelp |
|
Thanks pal-Jorel..
-vhelp |
Better yet this is the latest script Vhelp 8O
Quote:
|
Thanks friends.. all :)
Things are working great again, and I'm having fun. Can't wait till the weekend starts.. after being set back some. Keep up the good work all. -vhelp |
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.