View Single Post
Old 2nd February 2016, 23:36   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
SawBones(FrameSurgeon)

SawBones/FrameSurgeon, a VirtualDub2/Avisynth script, utility combo to edit bad frames.
Create Command file in VirtualDub2 with Sawbones, and use Command file in Avisynth script function FrameSurgeon().

SawBones.ReadMe.txt (v1.12) [Requires VirtualDub2 recent build 43602+, or thereabouts, and Windows system NotePad]
Code:
SawBones v1.12, (c) StainlessS @ Doom9:- https://forum.doom9.org/showthread.php?t=173158

SawBones/FrameSurgeon, a VirtualDub2/Avisynth script, utility combo to edit bad frames.

NOTE, VirtualDub2, formerly named VirtualDubFilterMod by 'Shekh the Magnificent':- https://forum.doom9.org/showthread.php?t=172021
(Sawbones v1.12 requires the new renamed version ie VirtualDub2, somewhere in the region of build 43602+).

Create Command file in VirtualDub2 [VDub2] with Sawbones, and use Command file in Avisynth script function FrameSurgeon.
SawBones now requires VirtualDub2, and also requires standard system NotePad, both NotePad and VDub2 AVS Script editor
windows should be open (you can make them smallish and leave them above/below the VDub2 main window). Sawbones will appear as a
little icon on the Right Hand Side of the task bar (SawBones does not have a window).

Quick intro:
    Create a Command.txt file and load into NotePad. Create a client script calling FrameSurgeon with args
        FrameSurgeon(...,Cmd="Command.txt",Final=False,Show=True)
    and open this client script in VDub2 and with the VDub2 Script editor window open, then run SawBones, now you are set to go.
        You can scroll through a video clip in VDub2, and press the SawBones "Frame Delete" key combo to insert a FrameSurgeon
    delete (DEL n) command for the current frame into the NotePad Editor. You press the keys with VDub2 as the active window (not NotePad).
    After entering the frame delete command, you could (if desired) then press the 'Save & Refresh' key combo, and the contents of
    NotePad Command.txt file will be saved, and then VDub2 will reload the script at the same position so you can see the deleted frame.
    (In actual fact, when using FrameSurgeon with Sawbones, you should use the FrameSurgeon args Final=False,Show=True, so that
    FrameSurgeon will not actually delete frames, but only mark the frames with some "DUMMY_DELETE" type subtitle in red,
    deleting them for real would screw up any further edits, plus you can scroll back and forth to see what
    frames will be deleted and perhaps spot any mistakes). Save your Command.txt file, you can now run the same client
    script with Final=True,Show=False to edit the clip for real, job done.


*** Current frame is shown in VDub2 in the middle of the status bar. ***
*** Ranges are marked in VDub2 via HOME and END keys, shown at Left of status bar (when marked). ***
*** FXd clips (where d is Digit 1-9) are user provided to FrameSurgeon.avs function and default to source clip if not user supplied. ***
*** Interpolation commands in FrameSurgeon are for Planar and YUY2 only (may depend upon mvtools version), others any colorspace. ***

It is important to NOT do any VDub2 clip editing, if you eg delete a frame in VDub2 [DELETE key], then all frames after
that frame will be off by 1, and so all SawBones edited ranges/frames inserted later into NotePad file will be also off by 1.
SawBones uses CTRL/DELETE and CTRL/SHIFT/DELETE keys for deletion, rather than VDub2 DELETE key.

The VDub2 loaded clip can be either an AVI or AVS clip, it makes no difference but the Save & Refresh command will NOT
work as expected with an AVI, as it will try to reload an avs script, not an AVI, so suggest that always use AVS as input to
VDub2 with Sawbones.
You could eg have a stacked avs script multi-window frame open in VDub2 so as to choose from your FXd clips within Sawbones.


All SawBones Keyboard commands that are inserted into NotePad command Text file:-

    CTRL/F1             CopyFromPrevious frame to current frame (ie replace source current frame n with source frame n - 1. (CP n)
    CTRL/F2             CopyFromNext frame to current frame (ie replace source current frame n with source frame n + 1. (CN n)

    CTRL/1              Replace current frame with same frame from FX1 clip. (FX1 n)
    CTRL/2              Replace current frame with same frame from FX2 clip. (FX2 n)
    CTRL/3              Replace current frame with same frame from FX3 clip. (FX3 n)
    CTRL/4              Replace current frame with same frame from FX4 clip. (FX4 n)
    CTRL/5              Replace current frame with same frame from FX5 clip. (FX5 n)
    CTRL/6              Replace current frame with same frame from FX6 clip. (FX6 n)
    CTRL/7              Replace current frame with same frame from FX7 clip. (FX7 n)
    CTRL/8              Replace current frame with same frame from FX8 clip. (FX8 n)
    CTRL/9              Replace current frame with same frame from FX9 clip. (FX9 n)

    CTRL/SHIFT/1        Replace range with same range from FX1 clip. (FX1 s,e)
    CTRL/SHIFT/2        Replace range with same range from FX2 clip. (FX2 s,e)
    CTRL/SHIFT/3        Replace range with same range from FX3 clip. (FX3 s,e)
    CTRL/SHIFT/4        Replace range with same range from FX4 clip. (FX4 s,e)
    CTRL/SHIFT/5        Replace range with same range from FX5 clip. (FX5 s,e)
    CTRL/SHIFT/6        Replace range with same range from FX6 clip. (FX6 s,e)
    CTRL/SHIFT/7        Replace range with same range from FX7 clip. (FX7 s,e)
    CTRL/SHIFT/8        Replace range with same range from FX8 clip. (FX8 s,e)
    CTRL/SHIFT/9        Replace range with same range from FX9 clip. (FX9 s,e)

    CTRL/SHIFT/ALT/1    Interpolate current frame n using source n-1 and n+1 as source frames. (I1 n)
    CTRL/SHIFT/ALT/2    Interpolate 2 frames starting at current frame n, using source n-1 and n+2 as source frames. (I2 n)
    CTRL/SHIFT/ALT/3    Interpolate 3 frames starting at current frame n, using source n-1 and n+3 as source frames. (I3 n)
    CTRL/SHIFT/ALT/4    Interpolate 4 frames starting at current frame n, using source n-1 and n+4 as source frames. (I4 n)
    CTRL/SHIFT/ALT/5    Interpolate 5 frames starting at current frame n, using source n-1 and n+5 as source frames. (I5 n)
    CTRL/SHIFT/ALT/6    Interpolate 6 frames starting at current frame n, using source n-1 and n+6 as source frames. (I6 n)
    CTRL/SHIFT/ALT/7    Interpolate 7 frames starting at current frame n, using source n-1 and n+7 as source frames. (I7 n)
    CTRL/SHIFT/ALT/8    Interpolate 8 frames starting at current frame n, using source n-1 and n+8 as source frames. (I8 n)
    CTRL/SHIFT/ALT/9    Interpolate 9 frames starting at current frame n, using source n-1 and n+9 as source frames. (I9 n)

    CTRL SHIFT ALT /    Interpolate Range. Ie in Avisynth Inclusive mode, where range is 100,101 [2 frames] then result = (I2 100)
                        The specified range start and end are the outer bad frames.
                        You can change this key combination used for "Interpolate Range" by changing the ini file item
                        "KEY_InterpolateRange=^+!{/}", to something else, in sequence they are CTRL(^) SHIFT(+), ALT(!) and '/' keys
                        pressed together. The Sawbones.ini file is created upon first use of the executable.

    CTRL/DELETE         Delete current frame. (DEL n) [FrameSurgeon Frame/Range deletes are processed AFTER ALL interpolations/replacements]
    CTRL/SHIFT/DELETE   Delete range (DEL s,e)
                            NOTE. If using below "Save & Refresh" with Avisynth loaded script, then DO NOT USE ANY delete commands
                        within SawBones UNLESS, you call FrameSurgeon with arg "FINAL=FALSE". The FrameSurgeon arg FINAL=FALSE,
                        causes FrameSurgeon to NOT actually delete frames, it will only MARK those frames as being targetted for deletion
                        (the frames will show some kind of DUMMY_DELETE text subtitled onto those frames). If you do not call FrameSurgeon with
                        FINAL=FALSE, then FrameSurgeon will indeed delete the frames, but VDub2/Sawbones will have no idea that
                        it has been done, and further replacements or deletions will be on the WRONG ranges.
                            IMPORTANT:- See also below Save & Refresh command.

    CTRL/SHIFT/ALT/,    Save & Refresh.
                        Ie, Save NotePad Command.txt, refresh/reload Avisynth Script, jumping back to original position in VDub2.
                        You can change this key combination used for "Save & Refresh" by changing the ini file item
                        "KEY_NotepadSaveAndRefresh=^+!{,}" to something else, in sequence they are CTRL(^) SHIFT(+), ALT(!) and ',' keys
                        pressed together. The Sawbones.ini file is created upon first use of the executable.
                        NOTE, it is quite difficult to find key combo's that are not used system wide, and also not used by VDub2.
                        It does also not improve matters where eg Graphics cards install a whole bunch of additional hotkey combos, reducing what
                        is available to the user. (Who actually thinks they need permanent system wide hotkeys to access graphic card settings,
                        almost useless and just an annoyance [particularly if they supplant your own hotkeys], disable if at all possible).
                        Some key combos may not work on some international keyboards and so you can change ALL key combos in the ini file,
                        a couple of URL links to further info will be embedded in the ini file.
                        Hopefully most Sawbones key combos are available to you, they were made deliberately a little awkard
                        in the hope that they are not used elsewhere on your system, if they already in-use then I'm afraid you may need to mod the
                        Sawbones ini file (after ascertaining what keys ARE available to you).
                        NOTE, Save & Refresh requires that VDub2 Script Editor window is also open to refresh the avisynth script
                          (perhaps best if you make it small and stack it next to the NotePad window).
                        If Script Editor is NOT open, then only a NotePad save of the Command text is done, we cannot refresh/reload the avs script
                        into VDub2 if script editor is not open.
                        IMPORTANT:- See also above DELETE commands.

    CTRL/SHIFT/ALT/PAUSE is TERMINATE Program (or close via System Tray icon). PAUSE is also known as BREAK, usually next to Scroll Lock.

NOTE: A range shown in VDub status bar as eg "Selecting Frames 100-102(2 frames)" represents frames 100 and 101, frame 102 is exclusive and
does not count. By default, SawBones uses Inclusive END frame ranges (same as Avisynth where end frame DOES count).
You can change the default behaviour to behave the same as VDub by Running SawBones.Exe at least once and changing the auto created
SawBones.ini file contents from "RangeEndIsExclusive=0" to "RangeEndIsExclusive=1". When using VDub "RangeEndIsExclusive=1" mode,
we subtract 1 from the End Frame to convert to Avisynth End Frame Inclusive specification when writing range to NotePad command.
When sending a command using VDub exclusive mode with a status bar range of "100-100(frames=0)", it will beep and show a "No Frames"
type error message for a few seconds, in Avisynth Inclusive mode it will send a 1 frame range command to the NotePad window.

It is easy to see what is happening as the NotePad window will be visible and after each insertion into NotePad, an ENTER key
will also be sent to move the cursor down one line, each command is on its own line. If you make a mistake, it is easy to
just switch to NotePad window and delete the erroneous line (Notepad window needs to be only a few lines tall).

Where same frames are flagged for replacment mulitple times, later one will take precidence.
All frame/range deletes will be done AFTER replacements, multiple deletes on same frame will only result on single frame deletion.
Already Interpolated frame/range CANNOT be replaced and will produce an error (In avs script), but they can be deleted.

FrameSurgeon.avs requires either AVS+ or GScript, MvTools, RT_Stats, FrameSel, ClipClop and Prune Plugins.

Sawbones.exe AutoiIt compiled executable with source provided (SawBones.au3), just click Menu Tools/build to create executable
(In Scite4AutoIt3 editor). Requires AutoIt3 and  Scite4AutoIt3 editor to re-build executable.
AutoIt:- https://www.autoitscript.com/site/
Also see Next post.

See next post.

See Mediafire or SendSpace below in my sig

Last edited by StainlessS; 13th August 2022 at 15:45. Reason: Update
StainlessS is offline   Reply With Quote