06-17-2003, 04:28 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
@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
|
Someday, 12:01 PM
|
|
Site Staff / Ad Manager
|
|
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
|
|
|
06-17-2003, 07:15 PM
|
Free Member
|
|
Join Date: Sep 2002
Location: Northfield, IL
Posts: 102
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 )
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
|
06-17-2003, 08:35 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Grantman
It appears you could conditionally apply the asharp(-2,0) on positive and nop() on negative?
|
That's exactly the way I had the script originally written:
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
|
06-18-2003, 05:09 AM
|
Free Member
|
|
Join Date: Mar 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
__________________
Regards, sh0dan // VoxPod
|
06-18-2003, 11:04 AM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
06-18-2003, 12:25 PM
|
Free Member
|
|
Join Date: Mar 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Fast solution:
sharp = asharp(-2,0)
conditionalfilter(last,sharp,last, "nf",">", "scd_trigger")
__________________
Regards, sh0dan // VoxPod
|
06-18-2003, 02:07 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by sh0dan
Fast solution:
sharp = asharp(-2,0)
conditionalfilter(last,sharp,last, "nf",">", "scd_trigger")
|
WAY more elegant
Thanks sh0dan
Updating script in a few moments
-kwag
|
06-18-2003, 02:57 PM
|
Free Member
|
|
Join Date: Mar 2003
Location: Denmark
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When I load a script with this new condionalfilter I'm getting an error in this line:
Quote:
Quote:
Script error: Invalid arguments to function "asharp"
|
...this is what I get when i open the script in windows media player
Anerboda
|
06-18-2003, 02:58 PM
|
Free Member
|
|
Join Date: Mar 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
So it uses last as the first argument for the filter. This is just a normal variable assignment, just as you always have done.
2) To optimize the first "scriptclip" away, try:
Code:
input = last
sharp_adaptive = scriptclip(input, "asharp( -(fmin((nf/30), 1)), 0 )")
temporal = TemporalSoften(input, 2,7,7,3,2)
Conditionalfilter(input, sharp_adaptive, temporal,"nf = YDifferenceToNext()"+chr(13)+"return nf", ">", "2.5",true)
This should be a bit faster- but try it out, before believing me. I made all implicit lasts explicit, by using "input" instead of nothing.
__________________
Regards, sh0dan // VoxPod
|
06-18-2003, 03:03 PM
|
Free Member
|
|
Join Date: Mar 2003
Location: Denmark
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When I put these two lines together it works
Quote:
sharp = asharp(-2,0)
conditionalfilter(last,sharp,last, "nf",">", "scd_trigger")
|
Like this:
Quote:
#
# Scene change detection - If a scene change is detected, we
# blur heavily. This affects the scene before and the one after the
# scene change, thus providing a softer transition for the encoder instead
# of a sharp "spike".
sharp = asharp(-2,0)
conditionalfilter(last,sharp,last, "nf",">", "scd_trigger")
#
#
#
|
Is this right??
Anerboda
|
06-18-2003, 03:18 PM
|
Free Member
|
|
Join Date: Mar 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
__________________
Regards, sh0dan // VoxPod
|
06-18-2003, 03:43 PM
|
Free Member
|
|
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks sh0dan,
I'll settle for conditionalfilter( last, asharp(-2,0), last, "nf", ">", "scd_trigger" ) just for user's simplicity
I know, I know, hard coded variables , but if the script starts to grow, then we'll all dress it up
-kwag
|
06-18-2003, 09:21 PM
|
Free Member
|
|
Join Date: Jan 2003
Posts: 1,009
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
@ 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
|
06-18-2003, 09:54 PM
|
Invalid Email / Banned / Spammer
|
|
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
06-18-2003, 09:56 PM
|
Free Member
|
|
Join Date: Jan 2003
Posts: 1,009
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks pal-Jorel..
-vhelp
|
06-18-2003, 10:09 PM
|
Free Member
|
|
Join Date: Jan 2003
Location: Puerto Rico
Posts: 423
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Better yet this is the latest script Vhelp
Quote:
### Ver. June 18, 2003 @20:35 GMT ###
Code:
## DLL Section ##
#
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\GripFit_YV12.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\asharp.dll")
LoadPlugin("C:\Filters25\undot.dll")
#
####
## Defined Variables and Constants ##
#
MaxTreshold = 1.50
scd_trigger = 30 # Scene change trigger value.
nf = 0 # Current frame.
#
####
## Main section and static filters ###
#
Mpeg2Source("Your_D2V_Source_Here")
#
undot()
Limiter()
asharp(2, 4)
GripCrop(Your_GripCrop_Parameters_Here)
GripSize(resizer="BicubicResize")
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
#
#
## Dynamic Linear Adaptive Filtering and Scene Change Detection ##
#
# ( Portions from AviSynth's manual ) - This will apply temporalsoften to
# very static scenes, and apply variable blur on moving scenes.
# We also assign a variable - and this is why a line break is inserted:
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2.5 ? asharp( -(fmin((nf/30), 1)), 0 ) : \
TemporalSoften(2,7,7,3,2) ")
#
# Scene change detection - If a scene change is detected, we
# blur heavily. This affects the scene before and the one after the
# scene change, thus providing a softer transition for the encoder instead
# of a sharp "spike".
conditionalfilter( last, asharp(-2,0), last, "nf", ">", "scd_trigger" )
#
#
#
GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()
#
#
## Functions ###
function fmin(float f1, float f2) {
return (f1<f2) ? f1 : f2
}
#
####
|
|
06-18-2003, 10:29 PM
|
Free Member
|
|
Join Date: Jan 2003
Posts: 1,009
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
All times are GMT -5. The time now is 04:52 AM — vBulletin © Jelsoft Enterprises Ltd
|