HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I had to update Prune() to x64 version, thought I had already done it.
Find below, some stuff.
Code:
Function FS_ExtractInterps(String InCmdFile,String OutCmdFile,Int "Extra") {
# Extra, 0=Interp only, 1=Interps + 1 before + 1 after, 2=Interps + 1 before + 1 after + Blank frame separator
Function FSX_IsNul(String S) {return RT_Ord(S)== 0}
Function FSX_IsHash(String S) {return RT_Ord(S)==35}
Function FSX_IsComma(String S) {return RT_Ord(S)==44}
Function FSX_IsHyphen(String S) {return RT_Ord(S)==45}
Function FSX_IsDigit(String S) {return (RT_Ord(S)>=48&&RT_Ord(S)<=57)}
Function FSX_EatWhite(String S) {pos=1 While(RT_Ord(S,pos=pos)==32||RT_Ord(S,pos=pos)==9){pos=pos+1} return(pos>1)?MidStr(S,pos):S}
Function FSX_EatDigits(String S) {pos=1 While(RT_Ord(S,pos=pos)>=48&&RT_Ord(S,pos=pos)<=57){pos=pos+1} return(pos>1)?MidStr(S,pos):S}
Function FSX_IsI(String S) {return s.RT_Ord == 73 || s.RT_Ord==105}
myName="FS_ExtractInterps: "
IsAvsPlus=FindStr(UCase(versionString),"AVISYNTH+")!=0
Assert(IsAvsPlus, RT_String("%sNeed AVS+",myName))
Assert(RT_FunctionExist("Prune"), RT_String("%sNeed Prune",myName))
Assert(InCmdFile!="", RT_String("%sInCmdFile Cannot be ''",myName))
InCmdFile=RT_GetFullPathName(InCmdFile)
Assert(InCmdFile.Exist, RT_String("%sInCmdFile Must Exist",myName))
Assert(OutCmdFile!="", RT_String("%sOutCmdFile Cannot be ''",myName))
OutCmdFile=RT_GetFullPathName(OutCmdFile)
Extra = Default(Extra,0)
Assert(0 <= Extra <= 2,RT_string("%s0 <= Extra <= 2",myName))
RT_FileDelete(OutCmdFile)
CMD=RT_ReadTxtFromFile(InCmdFile)
Lines=RT_TxtQueryLines(CMD)
CmdCnt=0
For(n=0,Lines-1) {
SSS=RT_TxtGetLine(Cmd,n).FSX_EatWhite
if(!SSS.FSX_IsNul && !SSS.FSX_IsHash) { # NOT Empty line or Hash (#) ALL Comment
if(SSS.FSX_IsI) {
S=SSS.MidStr(2) # Strip 'I'
if(S.FSX_IsDigit) {
Cnt=S.RT_NumberValue
Assert(0 < Cnt <= 9,RT_String("%sLINE_%d 'In' Invalid Interp Command\n'%s'",myName,n+1,SSS))
S=S.FSX_EatDigits.FSX_EatWhite
Assert(S.FSX_IsDigit,RT_String("%sLINE_%d Expecting Interpolate Start frame\n'%s'",myName,n+1,SSS))
SFrm=S.RT_NumberValue
EFrm=SFrm+Cnt-1
S=S.FSX_EatDigits.FSX_EatWhite
} else {
S=S.FSX_EatWhite
Assert(S.FSX_IsDigit,RT_String("%sLINE_%d Expecting Interpolate Start frame\n'%s'",myName,n+1,SSS))
SFrm=S.RT_NumberValue
EFrm=SFrm
S=S.FSX_EatDigits.FSX_EatWhite
if(S.FSX_IsComma) { S=S.MidStr(2).FSX_EatWhite } # Strip Comma and white
IsNeg = S.FSX_IsHyphen
if(IsNeg) { S=S.MidStr(2).FSX_EatWhite }
if(S.FSX_IsDigit) {
EFrm=S.RT_NumberValue
S=S.FSX_EatDigits.FSX_EatWhite
EFrm = (IsNeg) ? SFrm+EFrm-1 : EFrm
} Else { Assert(!IsNeg,RT_String("%sLINE_%d Expecting End frame\n'%s'",myName,n+1,SSS)) }
}
if(!S.FSX_IsHash) { Assert(S.FSX_IsNul,RT_String("%sLINE_%d UnExpect data\n'%s'",myName,n+1,SSS)) }
########
if(Extra>=1) { wr=RT_String("1 %d",SFrm-1).RT_StrPad(14) RT_WriteFile(OutCmdFile,"%s # BEFORE",wr,Append=True) } # Before
wr=RT_String("0 %d %d",SFrm,EFrm).RT_StrPad(14)
RT_WriteFile(OutCmdFile,"%s # INTERP <<<",wr,Append=True) # Interp
if(Extra>=1) { wr=RT_String("2 %d",EFrm+1).RT_StrPad(14) RT_WriteFile(OutCmdFile,"%s # AFTER",wr,Append=True) } # After
If(Extra==2) { wr="3 0".RT_StrPad(14) RT_WriteFile(OutCmdFile,"%s # BLANK",wr,Append=True) } # Blank
CmdCnt = CmdCnt + 1
} Else {
RT_DebugF("LINE_%d Skipping non Interp line\n '%s'",n+1,SSS,name=myName)
}
}
}
Return CmdCnt
}
Function PullInterpFrames(clip c, String InCmdFile, String "OutCmdFile",Int "Extra",Bool "Show",Bool "AutoDelOutCmd",bool "Debug") {
myName="PullInterpFrames: "
OutCmdFile=Default(OutCmdFile,"Prune_Cmd.txt")
Extra=Default(Extra,0)
Show=Default(Show)
AutoDelOutCmd=Default(AutoDelOutCmd,True) # If true, then delete OutCmdFile after use.
Debug=Default(Debug,false) # Prune Debugging output
dv = Debug ? 5 : 0
Assert(OutCmdFile!="", RT_String("%sOutCmdFile Cannot be ''",myName))
OutCmdFile=RT_GetFullPathName(OutCmdFile)
FS_ExtractInterps(InCmdFile,OutCmdFile,Extra) # extract Interpolation commands into OutcmdFile
blank=c.BlankClip(Length=1) # Single frame for blank separator when extra = 2
NickName=""" # Names Shown on each frame
Interpolated=0
Before=1
After=2
Blank=3
"""
Before=c After=c # Same as src, so we can show NickNames on frame.
Prune(c,Before,After,blank,Cmd=OutCmdFile,NickName=NickName,show=Show,dv=dv)
(AutoDelOutCmd) ? RT_FileDelete(OutCmdFile) : NOP
Return Last
}
Colorbars # Replace with your repaired clip returned via FrameSurgeon
InCmd="InCmd.txt" # Point to FrameSurgeon command file.
EXTRA=2 # 0=Interp only, 1=Interps + 1 before + 1 after, 2=Interps + 1 before + 1 after + Blank frame separator
SHOW=True
AutoDelOutCmd=False
PruneDebug=True
PullInterpFrames(InCmd,extra=EXTRA,show=SHOW,AutoDelOutCmd=AutoDelOutCmd,Debug=PruneDebug)
EDIT: Some Mods
InCmd.txt (ignore the comments, just testing working ok, Only extracts FrameSurgeon Interp commands (but tested with non interp commands in-situ).
Code:
CP 8
CN 12
#
I1 21 # Interpolate 1 frame n (using source frames n-1 and n+1 as Interpolation source frames, (Id commands Planar, YUY2 only).
I2 31 # Interpolate 2 frames starting at frame n, (using source frames n-1 and n+2).
I3 41 # Interpolate 3 frames starting at frame n, (using source frames n-1 and n+3).
I4 51 # Interpolate 4 frames starting at frame n, (using source frames n-1 and n+4).
I5 61 # Interpolate 5 frames starting at frame n, (using source frames n-1 and n+5).
I6 71 # Interpolate 6 frames starting at frame n, (using source frames n-1 and n+6).
I7 81 # Interpolate 7 frames starting at frame n, (using source frames n-1 and n+7).
I8 91 # Interpolate 8 frames starting at frame n, (using source frames n-1 and n+8).
I9 101 # Interpolate 9 frames starting at frame n, (using source frames n-1 and n+9).
I 111 # Interpolate 1 frame n (using source frames n-1 and n+1 as Interpolation source frames.
I 121,123 # Interpolate range s to e (max range 9 frames, using source frames s-1 and e+1 as source frames).
I 131,-2 # Interpolate frame count i, range s to s+i-1, (i max 9 frames, using source frames s-1 and s+i as source frames).
#
FXd 200 # Replace frame n with same frame from FXd clip, eg FX3 100 replace source frame 100 with same frame from FX3 clip.
FXd 210,212 # Replace range s to e with same range from FXd clip.
FXd 220,0 # Replace range s to end of clip with same range from FXd clip.
FXd 230,-i # Replace frame count i, range s to s+i-1, with same range from FXd clip.
# (the hyphen '-' indicates that i is a count rather than the end frame of a range).
#
DEL 240 # Delete frame n (Deletes are processed AFTER ALL Interpolations/replacements)
DEL 250,251 # Delete frames s to e
DEL 260,0 # Delete frames s to end of clip.
DEL 270,-2 # Delete frame count i, range s to s+i-1.
-300 # Delete frame n
-300,302 # Delete frames s to e
-400,0 # Delete frames s to end of clip.
-500,-2 # Delete frame count i, range s to s+i-1.
Generated Prune_Cmd.txt
Code:
1 20 # BEFORE
0 21 21 # INTERP <<<
2 22 # AFTER
3 0 # BLANK
1 30 # BEFORE
0 31 32 # INTERP <<<
2 33 # AFTER
3 0 # BLANK
1 40 # BEFORE
0 41 43 # INTERP <<<
2 44 # AFTER
3 0 # BLANK
1 50 # BEFORE
0 51 54 # INTERP <<<
2 55 # AFTER
3 0 # BLANK
1 60 # BEFORE
0 61 65 # INTERP <<<
2 66 # AFTER
3 0 # BLANK
1 70 # BEFORE
0 71 76 # INTERP <<<
2 77 # AFTER
3 0 # BLANK
1 80 # BEFORE
0 81 87 # INTERP <<<
2 88 # AFTER
3 0 # BLANK
1 90 # BEFORE
0 91 98 # INTERP <<<
2 99 # AFTER
3 0 # BLANK
1 100 # BEFORE
0 101 109 # INTERP <<<
2 110 # AFTER
3 0 # BLANK
1 110 # BEFORE
0 111 111 # INTERP <<<
2 112 # AFTER
3 0 # BLANK
1 120 # BEFORE
0 121 123 # INTERP <<<
2 124 # AFTER
3 0 # BLANK
1 130 # BEFORE
0 131 132 # INTERP <<<
2 133 # AFTER
3 0 # BLANK
Need Prune x64
EDIT: Non Interpolation commands that are skipped, are sent to the DebugView window (Google).
Last edited by StainlessS; 22nd December 2018 at 14:17.
|