View Single Post
Old 21st January 2018, 07:21   #59  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Real.Finder,
I've just tried your last script (with only the non-optional blendfactor fixed, and SFrameBlendX_limit removed), and to my amazement, it goes for about 2,600 frames.
It was pretty much what I tried earlier but I only removed Local=true, not knowing that True was the default when args used, so I should have set Local=false and would have got the same result as you.

I tried with your script and also SBX_MI, with a subtract and amplify (via ClipDelta function), and we are getting identical results.

EDIT: Although, when trying clip again, it sort of stuttered at about 1,600 frames, and then continued, not sure what happened there (try/catch ?).

Your script with slight mods.
Code:
Function SFrameBlendX(clip C, int blendfactor, string "blend_mode", float "blend_opacity") {
    C
    limit = (blendfactor<=0) ? 1 : Max(1, FrameCount/blendfactor)
    FrameCount!=1 ? ScriptClip("""
        try{bb=isclip(b)} catch(error_msg) {bb=false}
        b = bb ? limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0) : nop()
        b = bb ? b.Overlay(last, mode=blend_mode, opacity=blend_opacity) : last
        return b
    """,args="blend_mode, blend_opacity, limit", local=false) : last
}
EDIT: This still both stutters (~1400) and crashes at about 2,600 frames.
Code:
Function SFrameBlendX(clip C, int blendfactor, string "blend_mode", float "blend_opacity") {
    C
    limit = (blendfactor<=0) ? 1 : Max(1, FrameCount/blendfactor)
    FrameCount!=1 ? ScriptClip("""
        try{bb=isclip(b)} catch(error_msg) {bb=false}
        try {
            b = bb ? limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0) : nop
            b = bb ? b.Overlay(last, mode=blend_mode, opacity=blend_opacity) : last
        } catch(error_msg) {
            b=Last # attempt at reset, dont work.
        }
        return b
    """,args="blend_mode, blend_opacity, limit", local=false) : last
}
EDIT: By the way, the logic in the SBX_MI() script is the same as your original logic, pretty much, but being multi-instance you can run
two copies together, with Local=false in your script, the b variables (and perhaps others) would interfere with each other.

EDIT: Suggest that you study the SBX_MI thing, its really not a very complex script and does pretty much exactly what your script does,
the Martin53/Gavino Multi-instance interface makes for a very powerful little gizmo, with GScript and Grunt making things easy
to acheive, it would be worth your time having a play with it. All you have to remember is to add @@@ to global names and when
assigning to them always use Global x@@@=y, and copy the other stuff near the bottom of the SBX_MI script.

EDIT: Heres a little MI test script to help you figure out how it works:- https://forum.doom9.org/showthread.p...49#post1805249
Use DebugView (google) to see the messages.
Uncomment the RT_WriteFile line near the end to write the resultant script as a text file, it will be different for each
instance of the function.

Here, is instance 1 of SBX_MI
Code:
        Function Fn_SBX_MI_1(clip c,Int factor,String mode,Float opacity,Int limit) {
            n=current_frame
            if(Prev_SBX_MI_1 != n) {
                c
                cf=c.Trim(n,-1)                     # current frame
                if(Prev_SBX_MI_1 != n-1) {
                    Global B_SBX_MI_1 = cf                # First Frame OR User Jumping, Init/Reset to current frame
                } else {
                    # limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0)
                    if(limit > 1) {
                        Global B_SBX_MI_1 = Overlay(B_SBX_MI_1,cf, opacity=float(limit)/FrameCount)
                    } # Else, B_SBX_MI_1 = Previous B_SBX_MI_1

                    # b.Overlay(last, mode=mode, opacity=opacity)
                    # REMOVE '.FrameStore' from end of next line to crash this function.
                    Global B_SBX_MI_1=Overlay(B_SBX_MI_1,cf,mode=Mode,opacity=Opacity).FrameStore

                }
                Global Prev_SBX_MI_1=n                    # REM for next time
            } # Else, Cache failure, repeat request for current frame, just return same as last time
            Return B_SBX_MI_1
        }
        #######################################
        # Unique Global Variables Initialization
        #######################################
        Global Prev_SBX_MI_1=-666
        #######################################
        # Unique Runtime Call, GScriptClip must be a one-liner:
        #######################################
        ARGS = "Factor,Mode,Opacity,Limit"
        c.GScriptClip("Fn_SBX_MI_1(last, "+ARGS+")", local=true, args=ARGS)

EDIT: Maybe of interest:-
https://forum.doom9.org/showthread.php?t=169624

EDIT: Whatever that stutter is, we get different results when it happens.

EDIT: Found reason for different results when stutter, I originally used A, and B, instead of AC, and BC below, B was interfering with B in your script.
Code:
AviSource("Parade.avi")     # Some clip
AC=SFrameBlendX(10,"lighten",0.5)
BC=SBX_MI(10,"lighten",0.5)
ClipDelta(AC,BC,true)
__________________
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; 21st January 2018 at 09:36.
StainlessS is offline   Reply With Quote