View Single Post
Old 24th February 2019, 22:02   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
SCSelect was from a Kassandro plugin.

Here an equivalent function in script:- https://forum.doom9.org/showthread.p...38#post1633738

Code:
Avisource("D:\avs\test.avi")

# RemoveDirt's SCSelect(clip input, clip scene_begin, clip scene_end, clip global_motion, float dfactor, bool debug, bool planar)

Function SCSelect_Like(clip dclip,clip Start,clip End,clip Motion, float "dfactor",bool "debug") {
    # Start, End, Motion MUST all be same, dclip can be other colorspace/size (unlike SCSelect).
    dfactor=Float(Default(dfactor,4.0))
    debug=Default(debug,false)
    Global SCM_A=0.0 Global SCM_B=0.0 Global SCM_SC=0 Global SCM_Prev=-1
    Motion.ScriptClip("""
        NotNext = (current_frame!=SCM_Prev+1)
        Global SCM_A=(NotNext)? RT_LumaDifference(dclip,dclip,n=current_frame-1,n2=current_frame)  : SCM_B
        Global SCM_B=           RT_LumaDifference(dclip,dclip,n=current_frame,n2=current_frame+1)
        # 0 = Start of scene, 1 = End of scene, 2 = Global motion
        Global SCM_SC=(current_frame==FrameCount-1)?1:(SCM_A>dfactor*SCM_B || current_frame==0)?0:(SCM_B>dfactor*SCM_A)?1:2
        (SCM_SC==0) ? Start : (SCM_SC==1) ? End : Last      # Choose Start, End or Motion(ie Last)
        (debug)?RT_Subtitle("%d ] %6.2f %6.2f SC=%d",current_frame,SCM_A,SCM_B,SCM_SC):NOP
        Global SCM_Prev=current_frame
        Return Last
    """,args="dfactor,Start,End,Dclip,debug")          # Needs Grunt for args
    return Last
}

Start=Subtitle("START OF SCENE",align=3,size=30)
End=Subtitle("END OF SCENE", align=1,size=30)
Motion=Subtitle("GLOBAL MOTION",align=5,size=30)
Return SCSelect(Last,Start,End,Motion)
EDITED ABOVE client script: Should not call two instances on function which uses global Vars.

EDIT:
Code:
Function EndOfSceneClip(clip c,Int "thSCD1",Int "thSCD2") {   # All Luma Samples set 255 at EOS, else 0
    thSCD1=Default(thSCD1,400)  thSCD2=Default(thSCD2,130)
    sup=c.MSuper(pel=1,sharp=0,rfilter=2,hpad=16, vpad=16)
    bv=sup.MAnalyse(isb=true, delta=1,blksize=16)
    Return c.MSCDetection(bv,thSCD1=thSCD1,thSCD2=thSCD2)
}

Function StartOfSceneClip(clip c,Int "thSCD1",Int "thSCD2") { # All Luma Samples set 255 at SOS, else 0
    thSCD1=Default(thSCD1,400)  thSCD2=Default(thSCD2,130)
    sup=c.MSuper(pel=1,sharp=0,rfilter=2,hpad=16, vpad=16)
    fv=sup.MAnalyse(isb=false,delta=1,blksize=16)
    Return c.MSCDetection(fv,thSCD1=thSCD1,thSCD2=thSCD2)
}

Function SceneCutClip(clip c,Int "thSCD1",Int "thSCD2") {     # All Luma pixel = 0 =Norm, 1=EOS, 2=SOS, 3=EOS & SOS
    thSCD1=Default(thSCD1,400)  thSCD2=Default(thSCD2,130)
    Sup  = c.MSuper(pel=1,sharp=0,rfilter=2,hpad=16, vpad=16)
    BvEos= Sup.MAnalyse(isb=True,  delta=1,blksize=16)
    FvSos= Sup.MAnalyse(isb=False, delta=1,blksize=16)
    Eos  = c.MSCDetection(BvEos,thSCD1=thSCD1,thSCD2=thSCD2)
    Sos  = c.MSCDetection(FvSos,thSCD1=thSCD1,thSCD2=thSCD2)
    Return MT_Lutxy(Eos,Sos,yexpr="y 0 == x 0 == 0 1 ? x 0 == 2 3 ? ?",u=-128,v=-128)
}
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 24th February 2019 at 23:03.
StainlessS is offline   Reply With Quote