HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Post #4 of 4.
4) FrameSel_MakeReDupCmd
Code:
FrameSel_MakeReDupCmd(Clip c,String ofn, int F1, ... , int FN, String "SCmd"="", String "Cmd"="", \
Bool "Reject"=False, Bool "Debug"=False, Bool "Range"=True, Bool "Comments"=False)
FrameSel_MakeReDupCmd(), a function to take a duplicates frames command file and convert it to a FrameSel command file to
replace duplicates in source clip with duplicates that are identical to the predecessor frame of the first duplicate.
You could eg pull out non duplicates using FrameSel (with Reject=True), and do some kind of processing on those frames,
and then re-create duplicates but with identical duplicates using the processed clip as source for the newly inserted
identical duplicates. Motion Compensated processing would likely work better with duplicates removed first.
Identical Duplicates may be of some use in creating VFR (Variable Frame Rate) encodes, or in better compression where
many duplicates present.
The Reject arg provides you with the option of using a non dupe frames list rather that a dupe frames list and achieve
identical results, see later example.
Args identical to FrameSel (up to Reject), with exception of the additional compulsory 2nd String arg which is
an output filename, and missing Ordered (is always ordered), Ver and Show and Extract args.
See FrameSel() description for other arguments.
ofn, String, Compulsory.
Output file name. It is advised to use a different name to the Cmd file, although there is nothing to stop you
overwriting an original Cmd file if you like a little gamble.(Output file only written after fully read in and
all Ordering, Rejecting etc already processed. Only likely error would be during file writing eg eject floppy disk).
Range, bool, Default=True
False = Write individual frame numbers only, to output file.
True = (Default) Write comma separated Frame Ranges to output file (only where adjacent frames).
Comments, Bool, default False.
If true, then write additional descriptive comments to output file, else no comments written.
FrameSel_MakeReDupCmd, takes either Frame numbers as direct arguments, or in the SCmd string, or in the Cmd file (at least one must
be specified). If more than one command method is used, will process Cmd file first, then SCmd string second and lastly
directly supplied frame numbers. The command frames will be acted upon via the Reject arg (as in FrameSel, and here Ordered is ALWAYS
implied) and then re-written to the output command file. Any comments in SCmd string or Cmd file will not be written to the output
command file, where arg Comments=True, comments are auto generated to help decipher the output.
The FrameSel_MakeReDupCmd() function returns the total number of duplicate frames written to the output file.
Example:
# Script to test identical results if commands specified as either duplicates or non duplicates.
# Duplicates are synthesized as Blank Frames and will be replaced with duplicate of frame prior to first blank/dupe.
# Req ClipClop, RT_Stats, FrameSel plugins.
#######
CB=ColorBars.KillAudio.Trim(0,-20).ShowFrameNumber # 20 frames
BK=Last.BlankClip
#
CCDupeFrames=""" # ClipClop Duplicate Frame Numbers for creating test clip
1 3,5
1 9,11
1 15,17
"""
FSDupeFrames=""" # FrameSel Duplicate Frame Numbers (MUST NOT INLCUDE 0)
3,5
9,11
15,17
"""
#
CCNonDupeFrames=""" # ClipClop Non Duplicates Frame Numbers for creating test clip
1 0,2
1 6,8
1 12,14
1 18,19
"""
FSNonDupeFrames=""" # FrameSel Non Duplicates (MUST INCLUDE FRAME 0)
0,2
6,8
12,14
18,19
"""
####### CONFIG #####
AreDupes=True # If True then SCmd=list of duplicates, else list of non duplicates (SHOULD GET SAME RESULT)
####################
CCSCmd = (AreDupes) ? CCDupeFrames : CCNonDupeFrames
SCmd = (AreDupes) ? FSDupeFrames : FSNonDupeFrames
ORG = (AreDupes) ? ClipClop(CB,BK,scmd=CCSCmd) : ClipClop(BK,CB,scmd=CCSCmd)
#Return ORG
#######
ReDupFrames = "ReDupFrames.txt" # FrameSel command to re-assemble clip after processing. (created by FrameSel_MakeReDupCmd).
ReDupFrames = RT_GetFullPathName(ReDupFrames)
# Select Non Dupes Only for processing (Ordered always implied if Reject)
PreProc = Org.FrameSel(SCmd=SCmd,Reject=AreDupes,Ordered=True) # MUST be Ordered, Ordered=True, for when Reject=False
Processed = PreProc.McDegrainSharp(Frames=3) # Whatever Processing of non dupes
# Make Cmd file to recreate dups from processed predecessor (Reject=False if SCmd file specifies duplicates. else true if is non dupes)
FrameSel_MakeReDupCmd(ORG,ReDupFrames,Scmd=SCmd,Reject=!AreDupes,Debug=True,Range=True,Comments=True)
ReDupped=Processed.FrameSel(Cmd=ReDupFrames,Ordered=False) # Recreate Dups. (duplicates so cannot be Ordered)
#######
#return ReDupped
StackVertical(ORG,ReDupped)
#AudioDubEx(Last,ORG) # Restore audio
Return Last
Result for above script in ReDupFrames.txt command file.
Numbers in comments are output frame numbers, those prefixed by a 'D' are duplicates.
Below shows why you need in line ReDupped=Processed.FrameSel(Cmd=ReDupFrames,Ordered=False), Ordered=False, as we have
at beginning of file frames 0,2 ;2;2;2, so must not be ordered.
>>>>>>>>>>>>
0 ,2 # 0,2 [Len=3]
2 # D 3 # These are duplicates
2 # D 4
2 # D 5
3 ,5 # 6,8 [Len=3]
5 # D 9
5 # D 10
5 # D 11
6 ,8 # 12,14 [Len=3]
8 # D 15
8 # D 16
8 # D 17
9 ,10 # 18,19 [Len=2]
<<<<<<<<<<<<<
--------------------------------------
StainlessS.
EDIT: And here is my entry on WikiPedia (I've been around a long time, being dead dont arf put a crimp in my life )
https://en.wikipedia.org/wiki/Stainless_Stephen
Last edited by StainlessS; 27th July 2021 at 20:55.
|