View Single Post
Old 17th June 2013, 21:59   #9  |  Link
Aegwyn11
Registered User
 
Join Date: May 2011
Posts: 68
Thanks again for the awesome script. I modified it slightly to allow for use of pixel types other than YV12 (without altering the input clip pixel type).

Code:
Import("LocateFrames.avs") # Included in RT_Stats zip
# Based on FindFrame() (c) Gavino:   http://forum.doom9.org/showthread.php?p=1569622#post1569622
# Required: GScript    (c) Gavino:   http://forum.doom9.org/showthread.php?t=147846
# Required: RT_Stats   (c) StainlesS:http://forum.doom9.org/showthread.php?t=165479
# ---------------------------------------------------------------------------------
# Modified by Aegwyn11 - 6/17/2013 - Enabled so that any pixel type will work, not just YV12

Function SkipGreen(clip c,float "th",int "frames",int "R",int "G",int "B",bool "LastGreen") {
# Supply args OR change defaults (easier)
# Should supply non zero th OR change SkipGreen default.
    c
    th=Float(Default(th,0.0)) # 0.0==Search for 1st exact match or best possible if no exact match found]. Threshold 

for declaring match (diff <= Thresh).
    frames=Default(frames,250)      # Frames count to search
    R=Default(R,0)        G=Default(G,$FF)     B=Default(B,0)
    LastGreen=Default(LastGreen,false)
    Assert(R>=0 && R<=255 && G>=0 && G<=255 && B>=0 && B<=255,"SkipGreen: Bad color")
    Dclip=Trim(0,-frames)
    DClip = (!LastGreen) ? DClip : DClip.Reverse
    Green=c.BlankClip(Length=1,color=(R*256+G)*256+B,pixel_type="YV12")
#   Return Green
    s=DClip.ConvertToYV12().LocateFrames(Green,thresh=th,Chroma=True)
    Eval(s)
    Start = (LF_MATCH>=2) ? ((!LastGreen)?LF_FOUND:frames-1-LF_FOUND) + 1 : 0
#   RT_Debug("SkipGreen:","Trim(" + String(Start) + ",0)")
    Trim(Start,0)
#    Subtitle("Frame="+String(Start),Last_frame=0)
    Return Last
}
Aegwyn11 is offline   Reply With Quote