This works for a little bit longer (orig 825 frame, below 845 frames) before crash.
Code:
Function SBX_MI(clip c,int Factor, string "Mode", float "Opacity") {
c
myName = "SBX_MI: "
Mode = Default(Mode,"lighten")
Opacity = Default(Opacity,1.0)
Limit = (Factor<=0) ? 1 : Max(1, FrameCount/Factor)
FuncS="""
Function Fn@@@(clip c,Int factor,String mode,Float opacity,Int limit) {
n=current_frame
if(Prev@@@ != n) {
c
cf=c.Trim(n,-1) # current frame
if(Prev@@@ != n-1) {
Global B@@@ = 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@@@ = Overlay(B@@@,cf, opacity=float(limit)/FrameCount)
} # Else, B@@@ = Previous B@@@
# b.Overlay(last, mode=mode, opacity=opacity)
Global B@@@=Overlay(B@@@,cf,mode=Mode,opacity=Opacity) # HOW do we cache only this frame & release all others ?
}
Global Prev@@@=n # REM for next time
} # Else, Cache failure, repeat request for current frame, just return same as last time
Return B@@@
}
#######################################
# Unique Global Variables Initialization
#######################################
Global Prev@@@=-666
#######################################
# Unique Runtime Call, GScriptClip must be a one-liner:
#######################################
ARGS = "Factor,Mode,Opacity,Limit"
c.GScriptClip("Fn@@@(last, "+ARGS+")", local=true, args=ARGS)
"""
#######################################
# Unique Identifier Definition
#######################################
GIFunc="SBX_MI" # Function Name, Supply unique name for your multi-instance function.
GIName=GIFunc+"_InstanceNumber" # Name of the Instance number Global
RT_IncrGlobal(GIName) # Increment Instance Global (init to 1 if not already exists)
GID = GIFunc + "_" + String(Eval(GIName))
InstS = RT_StrReplace(FuncS,"@@@","_"+GID)
# RT_WriteFile("DEBUG_"+GID+".TXT","%s",InstS)
FrameCount!=1 ? GScript(InstS) : Last
Return Last
}
Client
Code:
aviSource("Parade.avi").trim(500,0)
SBX_MI(5)
EDIT: Made same mistake as in original, "Factor" was optional, removed quotes above.
EDIT: Perhaps Loop() added somewhere might delay crash ??? [EDIT: Nope, dont seem to work]
EDIT: Oops, added Int to Fn@@@(
Int Limit).
EDIT: Small mods.
EDIT:
Quote:
Originally Posted by Gavino
I think that could be fixed by setting local=false (default is 'true' when args is used), but I don't think it would fix real.finder's original problem.
|
I thought that I'de tried that, maybe I just tried without Local arg, perhaps Local is default true.
EDIT: Yep, default for Local=False, unless Args used, in which case default is True. (
I should have read above quote more closely).
EDIT: I did above test with AVS Standard, without AVS+ Trim() issue ongoing in Devs forum, Avisynth+ Thread.
https://forum.doom9.org/showthread.p...02#post1830902
EDIT: Above, we are using Global B@@@ as a single frame accumulator for all previous frames overlayed, we need some method to cache only that frame, and release all prevous ones.