View Full Version : scriptclip problems
Wilbert
2nd July 2003, 20:31
I was trying scriptclip (on some almost black frames), and got the following output:
# gives 43.66
clip = clip.Trim(0,-1)
ScriptClip(clip, "Subtitle(String(AverageLuma(clip)))")
# first frame: 43.656
# second frame: 43.395
# third frame: 43.405
clip = clip.Trim(0,-3)
ScriptClip(clip, "Subtitle(String(AverageLuma(clip)))")
# gives 0.00002
clip = clip.Trim(0,-1)
ScriptClip(clip, "Subtitle(String(YDifferenceFromPrevious))")
# first frame: 2.271
# second frame: 0.00002
# third frame: 2.137
clip = clip.Trim(0,-3)
ScriptClip(clip, "Subtitle(String(YDifferenceFromPrevious))")
There are two things which I don't understand:
1) Mustn't the order in the last example be 0.00002, 2.271, 2.137 instead of 2.271, 0.00002, 2.137.
2) Even then, I don't understand these values. I also added the calculation of averageluma. The difference between the first two frames, for example, is 43.656 - 43.395 = 0.261. Which is not approx. equal to 2.271?
Cross
3rd July 2003, 00:31
I posted something very similar a few days ago.
http://forum.doom9.org/showthread.php?s=&goto=lastpost&threadid=50105
But no answer. :(
Bye
Cross
sh0dan
3rd July 2003, 12:52
I'll try fiddling around with it to get some answers.
Wilbert
3rd July 2003, 21:24
One more question, if you don't mind :) I'm trying to understand the "Quantified Motion Filter: adaptive motion filter for Avisynth", in the thread: http://forum.doom9.org/showthread.php?s=&threadid=56051
This script:
# first frame: 2.271
# second frame: 0.00002
# third frame: 2.137
# fourth frame: 2.252
clip = clip.Trim(0,-4)
ScriptClip(clip, "Subtitle(String(YDifferenceFromPrevious))")
gives exactly the same output as the following script:
clip = clip.Trim(0, -4)
function g(clip c)
{
global clip=c
c=ScriptClip(c, "debug()")
c=FrameEvaluate(c, "me")
c=FrameEvaluate(c, "global text=YDifferenceFromPrevious(clip)")
return c
}
function me()
{
global t=String(text)
}
function debug(clip c)
{
c = subtitle(c, t)
return c
}
g(clip)
The problem is that I don't understand what is happening here. If you look at the function "g" it appears that the script is executed backwards (instead of forwards, which is normally the case). Thus the globale variable "text" is obtained, and used by the function "me" [which is located above that line]. Then the "debug" function is applied [which is located above that line].
I know that AviSynth parses (or reads) from bottom to top, so I guess that has something to do with it. I just don't understand this, and I'm so confused :confused:
HomiE FR
3rd July 2003, 22:15
Wilbert wrote:
I just don't understand this, and I'm so confused.
And so I am! :)
If an explanation is possible, I'd like to hear/read it. Thanks sh0dan (I won't get bored by saying it again and again :p ).
sh0dan
3rd July 2003, 22:25
It because of how AviSynth works.
Scripts are parsed from top to bottom, but when a frame is requested the last filter is actually being invoked first, requesting frames upwards in the filter chain. For example:
AviSource("myfile.avi")
ColorYUV(analyze=true)
Histogram()
- When Vdub requests a frame, AviSynth requests the frame from Histogram.
- Histogram requests a frame from ColorYUV,
- ColorYUV from AviSource, which produces the frame, and delivers it to ColorYUV.
- ColorYUV processes the image and sends it on to Histogram, which returns it to Vdub.
So the filter chain basicly works backwards, which gives filter the possibility to request several frames from the source above.
Conditional filters need to evaluate scripts BEFORE they request frames from the filter above, because they need to know which filter to call.
I guess I owe it to you to write some decent explanation of this. Cond. filters are quite complex - and sometimes I am even surprised of the outcome. ;)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.