Log in

View Full Version : help on script


You Know
11th July 2004, 23:30
Hi i need help for with little script.

My purpose is detect scene switch by script. i would improve the blended filed before and next bad frame after scene switch.


function DetectSceneChange(clip c)
{ return (YDifferenceFromPrevious() > 20) ? (UDifferenceFromPrevious() > 5.5) ? (VDifferenceFromPrevious() > 4.5) ? 1:0 :0 :0
}

MPEG2Source("F:\gto\gto.d2v",idct=4)
AssumeTFF()

SeparateFields()

ConvertToYV12()
even = SelectEven()
odd = Selectodd()

f = DetectSceneChange(even)

even = ConditionalFilter(even, even.DeleteFrame(0), even, "f", "=", "1")
odd = ConditionalFilter(odd, odd.DeleteFrame(0), odd, "f", "=", "1")

return Interleave(even, odd).weave()


I would calculate YUV Difference only one time and not one for each stream because the scene switch is same for both top and bottom field, but I do not understand how to do a working script. Anyone can help?

Wilbert
12th July 2004, 09:40
You forgot to define the global variables. I don't have time to look at it before tonight.

You Know
12th July 2004, 15:03
i do not understand use of global variable (i am scripting newbe).

i will attend tonight thanks

Wilbert
13th July 2004, 23:22
I think this script does what you want


MPEG2Source("F:\From_hell\from_hell.d2v")
SeparateFields()
even = SelectEven()
odd = Selectodd()

# initialization
global b=0
global diffY=0
global diffU=0
global diffV=0

even = ConditionalFilter(even, even.DeleteFrame(0), even, "b", "=", "1")
even = FrameEvaluate(even, "DetectSceneChange()")

odd = ConditionalFilter(odd, odd.DeleteFrame(0), odd, "b", "=", "1")
odd = FrameEvaluate(odd, "DetectSceneChange()")

Interleave(even, odd).weave()



function DetectSceneChange(clip c)
{
global w = c
global b = (diffY > 20) ? (diffU > 5.5) ? (diffV > 4.5) ? 1 : 0 : 0 : 0
c = FrameEvaluate(c, "global diffV = VDifferenceFromPrevious(w)")
c = FrameEvaluate(c, "global diffU = UDifferenceFromPrevious(w)")
c = FrameEvaluate(c, "global diffY = YDifferenceFromPrevious(w)")
return c
}


1) Remember that the values in the conditional environment (like diffY, diffU, diffV and b) get assigned backwards, but you have to initialize them though.

2) If you want to use values from variables (like diffY in DetectSceneChange) which are defined in the conditional environment outside the conditional environment, you have to defined them globally.

Check out the examples in http://www.avisynth.org/ConditionalFilter (part I and III).

You Know
18th August 2004, 23:33
hi i have installed last version of avisynth RC1 and all
YDifferenceFromPrevious
YDifferenceToNext

does not work anymore i have try all example found in help and on web page

for example

clip = AviSource("c:\file.avi")
ScriptClip(clip, "Subtitle(String(YDifferenceFromPrevious))")


error

Evaluate: Unknow exception!
([ScriptClip:] line 1)


is a bug???

EDIT: i just come back to AVS 2.5.5 beta2(29-07-04) and it works so i'm sure that is a bug of RC1