StainlessS
6th April 2019, 02:38
Prompted by "Delete Lines In Image" Thread:- https://forum.doom9.org/showthread.php?t=176247
NumCommandProcessor_ReadMe.txt
# NumCommandProcessor_ReadMe.txt
# IMPORT Avsi files
NumCommandProcessor.avsi Command generator. https://forum.doom9.org/showthread.php?p=1870956#post1870956
PixelRemDup.avsi Pixel Row/Column Remove/Duplicate utility functions.
NumCommandUtility.avsi Utility functions, only MySub() at present, add your own.
# Client AVS files
NumCommandProcessor_DEMO.avs # Generator Demo Client.
NumCommand_LOG_DEMO.avs # Log Import and view result clip.
# Pre-Generated LOGFile, just all demo functions collected into single log file. Use NumCommand_LOG_DEMO.avs to Import and View clip.
MyLog.Log
ssS
NumCommandProcessor.avsi [Part 1 of 2]
# NumCommandProcessor.avsi
/*
NumCommandProcessor(), v1.02 by StainlessS @ Doom9 : https://forum.doom9.org/showthread.php?p=1870956#post1870956
Call some clip function with int command args taken from a Command String or File.
Can write/append generated commands to Logfile for further hand edit and frameserve with raw log commands and without NumCommandProcessor.
Required:-
RT_Stats v1.43+ [(c) StainlessS]
Avs+ [(c) Ultim, Pinterf & others], OR GScript [(c) Gavino].
NumCommandProcessor(clip c, String CMD,String CmdFunc,Int "NumMax"=c.Framecount-1,Int "NumMaxStep"=0,Bool "Reverse"=False,Bool "Debug"=True,String "LogFile"="",Bool "LogAppend") : returns result clip
Two modes of operation governed by CmdFunc string,
1 ) EMBEDDED single Number, eg "DeleteFrame(%d)" where Commands in CMD(String or File) must be single integer number only, no ranges allowed.
'%d' in above string is the insertion point for the integers read from CMD String or File.
If CmdFunc function is some kind of Delete or Insert function eg DeleteFrame or DuplicateFrame or RemovePixelRow or etc, then assuming the CMD string/file
integers are in ascending order, then should set Reverse=True, as when deleting/inserting something, higher number eg frames will move by 1 place due to the deleted/inserted frame/pixelRow.
In addition, if eg deleting frames, then should also set NumMaxStep=-1, to reduce the frame count so that validation check is decremented after each frame deleted.
If CmdFunc is some kind of Insertion function eg "DuplicateFrame(%d)" then should set NumMaxStep=1 as frame count will grow at every frame duplicate insertion.
If ANY kind of EMBEDDED non frame style function, eg "RemovePixelRow(%d)" then MUST set NumMax = c.Height-1 to validate cmd integers against height, and if eg
"RemovePixelColumn(%d)" then set NumMax = c.Width-1 (assuming that your clip is called c).
2 ) APPLYRANGE (NON-EMBEDDED), eg "Blur(1.58,1.58)" [NO insertion point ie no embedded '%d'].
In this mode, the CmdFunc is applied using ApplyRange with the numbers obtained from the CMD string/file (Can be single frame or range).
NEITHER of the above modes are of any use for trimming a clip, if you require command file for trimming ranges see
FrameSel Plugin (Especially SelectRanges.avs, which also requires Prune if trimming audio)
FrameSel:- https://forum.doom9.org/showthread.php?t=167971&highlight=FrameSel
Prune:- https://forum.doom9.org/showthread.php?t=162446
FrameSel SelectRanges.avs allows for Either Selecting or Rejecting command frames/ranges.
CMD, If First character is an Asterisk(*) then is interpreted as a multiline Command String of command numbers[one number/range per line], Otherwise a FileName of command numbers.
EMBEDDED mode allows only single Integers in CMD, whereas APPLYRANGE mode allows for 1 (frame) or 2 (range) on any command line.
Best if numbers/ranges in ascending order, and non overlapping ranges suggested (but not enforced).
CmdFunc, Function Name and optional positional insertion marker '%d' where the command number will be inserted, eg "DeleteFrame(%d)".
Do not include source clip, uses Last as in "DeleteFrame(%d)" or "Blur(1.58,1.58)".
See previously noted EMBEDDED and APPLYRANGE (NON-EMBEDDED) modes.
Do not use more than 1 insertion marker, it will produce error alert (there are no checks).
NumMax, Default c.FrameCount-1.
Maximum possible valid command number for validation, eg if "DeleteFrame(%d)" then use c.FrameCount-1, or for "RemovePixelRow(%d)" then c.Height-1,
For "RemovePixelColumn(%d)" use c.Width-1, etc (assuming that your clip is called c).
For APPLYRANGE (Non-EMBEDDED) mode, always set as as Default c.FrameCount-1.
NumMaxStep, Default 0. (Range: -1, or 0, or 1 ONLY)
Adjustment to NumMax validation check after some EMBEDDED mode delete or insert style CmdFunc,
eg use NumMaxStep=-1 for "DeleteFrame(%d)" or "RemovePixelRow(%d)" and NumMaxStep=1 for "DuplicateFrame(%d)" or "DuplicatePixelRow(%d)".
NOT USED in APPLYRANGE mode.
Reverse, Default False. If True, then Process CMD list of numbers in reverse order, from bottom of list to top, Else from top to bottom.
If eg Deleting or Inserting frames, then after each operation, all frames above would change their frame number, so must do in reverse order.
Probably does not really matter in APPLYRANGE mode unless ranges overlap (which they really should not).
Debug, Default True. Send Func calls to DebugView as each are called (Google DebugView) .
LogFile, Default "" ie No Log file. Give it a Filename to Produce log of commands used.
LogAppend, Default False. Only valid if LogFile!="". If True, then Append to existing Logfile, else Delete existing Logfile at Start.
LogFile and LogAppend, allow you to 'Collect' a bunch of generated commands for perhaps further hand edit, using NumCommandProcessor
just to generate a template with correct frames/ranges (including Reverse order if necessary, and validating ranges),
then make small adjustments eg Change Subtitle text or colors for one off adjustment.
Returns result clip after all commands executed, ALL processing of frames/ranges done before frame serving commences.
Eg >>>>>>>>>>>>>>>>>>>>>>>>>>>
Import(".\NumCommandProcessor.avsi")
Import(".\NumCommandUtility.avsi")
Import(".\PixelRemDup.avsi")
Colorbars(Width=1024,Height=768).KillAudio.ConvertToYV24.ShowFrameNumber
CMD="""* # <<<<<<<========== If 1st Character is Asterisk/Star ['*'] Then is a Command String, ELSE is a FileName.
100
200
300
400
500
"""
#CMD="CMD.txt" # Alternate use where numbers in File (same format)
RANGECMD="""* # <<<<<<<========== If 1st Character is Asterisk/Star ['*'] Then is a Command String, ELSE is a FileName.
100 149
200, 299
400
500 ,599
"""
#RANGECMD="RANGECMD.txt" # Alternate use where numbers in File (same format)
LOGFILE="MyLog.Log" # APPEND All to Log (Default="" ie not used)
LOGAPPEND=TRUE # APPEND All to Log (Default=FALSE, ie Delete LOG at start)
############################
## Pick One of below to Return, comment out others (Reverse assumes that CMD/RANGECMD are in ascending order)
## EMBEDDED mode frame Deletion / Insertion (Using CMD)
Return NumCommandProcessor(CMD,"DuplicateFrame(%d)",NumMaxStep=1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Insertion so REVERSE=True and NumMaxStep=1
#Return NumCommandProcessor(CMD,"DeleteFrame(%d)",NumMaxStep=-1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Deletion so REVERSE=True and NumMaxStep=-1
## APPLYRANGE modes (Using RNGCMD) NO Optional names allowed, and ALL (used) args in proper order (ApplyRange requirement).
#Return NumCommandProcessor(RANGECMD,"FlipVertical",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # APPLYRANGE, Accept Defaults, Frame or Range Commands
#Return NumCommandProcessor(RANGECMD,"FlipHorizontal",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info #
#Return NumCommandProcessor(RANGECMD,"Blur(1.58,1.58)",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info #
#Return NumCommandProcessor(RANGECMD,"Sharpen(1.0,1.0)",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info #
#Return NumCommandProcessor(RANGECMD,"Levels(24,1.2,220,16,235,false)",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # NO Optional names allowed, and in order.
#Return NumCommandProcessor(RANGECMD,"""MySub("Hello, World!","Ariel",64,$FF5555,$0,5)""",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # NO Optional names allowed, and in order.
## EMBEDDED pixel row/col Delete/Insert. (Using CMD)
## Assumes that you have RemovePixelRow, RemovePixelColumn, DuplicatePixelRow, and DuplicatePixelColumn script functions.
#Return NumCommandProcessor(CMD,"DuplicatePixelRow(%d)",NumMax=Height-1,NumMaxStep=1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Insertion so REVERSE=True and NumMaxStep=1
#Return NumCommandProcessor(CMD,"RemovePixelRow(%d)",NumMax=Height-1,NumMaxStep=-1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Deletion so REVERSE=True and NumMaxStep=-1
#Return NumCommandProcessor(CMD,"DuplicatePixelColumn(%d)",NumMax=Width-1,NumMaxStep=1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Insertion so REVERSE=True and NumMaxStep=1
#Return NumCommandProcessor(CMD,"RemovePixelColumn(%d)",NumMax=Width-1,NumMaxStep=-1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Deletion so REVERSE=True and NumMaxStep=-1
<<<<<<<<<<<<<<<<<<<<<<<<<<<
*/
Append next post (Copy/Paste)
Or find zip file @ MediaFire or SendSpace below this post.
NumCommandProcessor_ReadMe.txt
# NumCommandProcessor_ReadMe.txt
# IMPORT Avsi files
NumCommandProcessor.avsi Command generator. https://forum.doom9.org/showthread.php?p=1870956#post1870956
PixelRemDup.avsi Pixel Row/Column Remove/Duplicate utility functions.
NumCommandUtility.avsi Utility functions, only MySub() at present, add your own.
# Client AVS files
NumCommandProcessor_DEMO.avs # Generator Demo Client.
NumCommand_LOG_DEMO.avs # Log Import and view result clip.
# Pre-Generated LOGFile, just all demo functions collected into single log file. Use NumCommand_LOG_DEMO.avs to Import and View clip.
MyLog.Log
ssS
NumCommandProcessor.avsi [Part 1 of 2]
# NumCommandProcessor.avsi
/*
NumCommandProcessor(), v1.02 by StainlessS @ Doom9 : https://forum.doom9.org/showthread.php?p=1870956#post1870956
Call some clip function with int command args taken from a Command String or File.
Can write/append generated commands to Logfile for further hand edit and frameserve with raw log commands and without NumCommandProcessor.
Required:-
RT_Stats v1.43+ [(c) StainlessS]
Avs+ [(c) Ultim, Pinterf & others], OR GScript [(c) Gavino].
NumCommandProcessor(clip c, String CMD,String CmdFunc,Int "NumMax"=c.Framecount-1,Int "NumMaxStep"=0,Bool "Reverse"=False,Bool "Debug"=True,String "LogFile"="",Bool "LogAppend") : returns result clip
Two modes of operation governed by CmdFunc string,
1 ) EMBEDDED single Number, eg "DeleteFrame(%d)" where Commands in CMD(String or File) must be single integer number only, no ranges allowed.
'%d' in above string is the insertion point for the integers read from CMD String or File.
If CmdFunc function is some kind of Delete or Insert function eg DeleteFrame or DuplicateFrame or RemovePixelRow or etc, then assuming the CMD string/file
integers are in ascending order, then should set Reverse=True, as when deleting/inserting something, higher number eg frames will move by 1 place due to the deleted/inserted frame/pixelRow.
In addition, if eg deleting frames, then should also set NumMaxStep=-1, to reduce the frame count so that validation check is decremented after each frame deleted.
If CmdFunc is some kind of Insertion function eg "DuplicateFrame(%d)" then should set NumMaxStep=1 as frame count will grow at every frame duplicate insertion.
If ANY kind of EMBEDDED non frame style function, eg "RemovePixelRow(%d)" then MUST set NumMax = c.Height-1 to validate cmd integers against height, and if eg
"RemovePixelColumn(%d)" then set NumMax = c.Width-1 (assuming that your clip is called c).
2 ) APPLYRANGE (NON-EMBEDDED), eg "Blur(1.58,1.58)" [NO insertion point ie no embedded '%d'].
In this mode, the CmdFunc is applied using ApplyRange with the numbers obtained from the CMD string/file (Can be single frame or range).
NEITHER of the above modes are of any use for trimming a clip, if you require command file for trimming ranges see
FrameSel Plugin (Especially SelectRanges.avs, which also requires Prune if trimming audio)
FrameSel:- https://forum.doom9.org/showthread.php?t=167971&highlight=FrameSel
Prune:- https://forum.doom9.org/showthread.php?t=162446
FrameSel SelectRanges.avs allows for Either Selecting or Rejecting command frames/ranges.
CMD, If First character is an Asterisk(*) then is interpreted as a multiline Command String of command numbers[one number/range per line], Otherwise a FileName of command numbers.
EMBEDDED mode allows only single Integers in CMD, whereas APPLYRANGE mode allows for 1 (frame) or 2 (range) on any command line.
Best if numbers/ranges in ascending order, and non overlapping ranges suggested (but not enforced).
CmdFunc, Function Name and optional positional insertion marker '%d' where the command number will be inserted, eg "DeleteFrame(%d)".
Do not include source clip, uses Last as in "DeleteFrame(%d)" or "Blur(1.58,1.58)".
See previously noted EMBEDDED and APPLYRANGE (NON-EMBEDDED) modes.
Do not use more than 1 insertion marker, it will produce error alert (there are no checks).
NumMax, Default c.FrameCount-1.
Maximum possible valid command number for validation, eg if "DeleteFrame(%d)" then use c.FrameCount-1, or for "RemovePixelRow(%d)" then c.Height-1,
For "RemovePixelColumn(%d)" use c.Width-1, etc (assuming that your clip is called c).
For APPLYRANGE (Non-EMBEDDED) mode, always set as as Default c.FrameCount-1.
NumMaxStep, Default 0. (Range: -1, or 0, or 1 ONLY)
Adjustment to NumMax validation check after some EMBEDDED mode delete or insert style CmdFunc,
eg use NumMaxStep=-1 for "DeleteFrame(%d)" or "RemovePixelRow(%d)" and NumMaxStep=1 for "DuplicateFrame(%d)" or "DuplicatePixelRow(%d)".
NOT USED in APPLYRANGE mode.
Reverse, Default False. If True, then Process CMD list of numbers in reverse order, from bottom of list to top, Else from top to bottom.
If eg Deleting or Inserting frames, then after each operation, all frames above would change their frame number, so must do in reverse order.
Probably does not really matter in APPLYRANGE mode unless ranges overlap (which they really should not).
Debug, Default True. Send Func calls to DebugView as each are called (Google DebugView) .
LogFile, Default "" ie No Log file. Give it a Filename to Produce log of commands used.
LogAppend, Default False. Only valid if LogFile!="". If True, then Append to existing Logfile, else Delete existing Logfile at Start.
LogFile and LogAppend, allow you to 'Collect' a bunch of generated commands for perhaps further hand edit, using NumCommandProcessor
just to generate a template with correct frames/ranges (including Reverse order if necessary, and validating ranges),
then make small adjustments eg Change Subtitle text or colors for one off adjustment.
Returns result clip after all commands executed, ALL processing of frames/ranges done before frame serving commences.
Eg >>>>>>>>>>>>>>>>>>>>>>>>>>>
Import(".\NumCommandProcessor.avsi")
Import(".\NumCommandUtility.avsi")
Import(".\PixelRemDup.avsi")
Colorbars(Width=1024,Height=768).KillAudio.ConvertToYV24.ShowFrameNumber
CMD="""* # <<<<<<<========== If 1st Character is Asterisk/Star ['*'] Then is a Command String, ELSE is a FileName.
100
200
300
400
500
"""
#CMD="CMD.txt" # Alternate use where numbers in File (same format)
RANGECMD="""* # <<<<<<<========== If 1st Character is Asterisk/Star ['*'] Then is a Command String, ELSE is a FileName.
100 149
200, 299
400
500 ,599
"""
#RANGECMD="RANGECMD.txt" # Alternate use where numbers in File (same format)
LOGFILE="MyLog.Log" # APPEND All to Log (Default="" ie not used)
LOGAPPEND=TRUE # APPEND All to Log (Default=FALSE, ie Delete LOG at start)
############################
## Pick One of below to Return, comment out others (Reverse assumes that CMD/RANGECMD are in ascending order)
## EMBEDDED mode frame Deletion / Insertion (Using CMD)
Return NumCommandProcessor(CMD,"DuplicateFrame(%d)",NumMaxStep=1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Insertion so REVERSE=True and NumMaxStep=1
#Return NumCommandProcessor(CMD,"DeleteFrame(%d)",NumMaxStep=-1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Deletion so REVERSE=True and NumMaxStep=-1
## APPLYRANGE modes (Using RNGCMD) NO Optional names allowed, and ALL (used) args in proper order (ApplyRange requirement).
#Return NumCommandProcessor(RANGECMD,"FlipVertical",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # APPLYRANGE, Accept Defaults, Frame or Range Commands
#Return NumCommandProcessor(RANGECMD,"FlipHorizontal",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info #
#Return NumCommandProcessor(RANGECMD,"Blur(1.58,1.58)",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info #
#Return NumCommandProcessor(RANGECMD,"Sharpen(1.0,1.0)",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info #
#Return NumCommandProcessor(RANGECMD,"Levels(24,1.2,220,16,235,false)",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # NO Optional names allowed, and in order.
#Return NumCommandProcessor(RANGECMD,"""MySub("Hello, World!","Ariel",64,$FF5555,$0,5)""",LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # NO Optional names allowed, and in order.
## EMBEDDED pixel row/col Delete/Insert. (Using CMD)
## Assumes that you have RemovePixelRow, RemovePixelColumn, DuplicatePixelRow, and DuplicatePixelColumn script functions.
#Return NumCommandProcessor(CMD,"DuplicatePixelRow(%d)",NumMax=Height-1,NumMaxStep=1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Insertion so REVERSE=True and NumMaxStep=1
#Return NumCommandProcessor(CMD,"RemovePixelRow(%d)",NumMax=Height-1,NumMaxStep=-1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Deletion so REVERSE=True and NumMaxStep=-1
#Return NumCommandProcessor(CMD,"DuplicatePixelColumn(%d)",NumMax=Width-1,NumMaxStep=1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Insertion so REVERSE=True and NumMaxStep=1
#Return NumCommandProcessor(CMD,"RemovePixelColumn(%d)",NumMax=Width-1,NumMaxStep=-1,Reverse=True,LogFile=LOGFILE,LogAppend=LOGAPPEND).Info # Embedded, Deletion so REVERSE=True and NumMaxStep=-1
<<<<<<<<<<<<<<<<<<<<<<<<<<<
*/
Append next post (Copy/Paste)
Or find zip file @ MediaFire or SendSpace below this post.