Log in

View Full Version : Virtualdub keyboard macro


konstantin1
26th January 2016, 21:21
I would like to browse through frames of a video, and extracting certain segments. To do this, I want record frame numbers (a lot of them) of the segments: starting frame, ending frame, ...
or :
starting frame
ending frame
...
Format doesn't count. I can easily convert then.

When I reached the needed content in the video while seeking through it , I simply would press a key and I want to log the current frame number (or timecode equivalently) to a text file. I want to do this because another program would use those list of frame numbers.

Is it possible with VirtualDub? Maybe with a plugin? Or should I use any other app? Please advice me any similar app, in which I am able to set such a keyboard macro. I would prefer apps which can open avs files, but nut crucial.

ChiDragon
26th January 2016, 21:54
I'm sure there are better solutions, but in the past I occasionally used this AutoIt script I wrote to copy frame numbers from VirtualDub to the clipboard.

The hotkey is the semicolon key (;). You can change this to whatever key combo you like and modify the script to write to a text file (https://www.autoitscript.com/autoit3/docs/functions/FileWriteLine.htm) every time you press the hotkey instead of copying to clipboard.

Of course, you will also need to change the VDub version number listed in the script to whichever one you use. It uses this text string to find the appropriate window.

When you install AutoIt, you can compile this to an EXE file or just run the script by right-clicking on a text file with extension AU3.


; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x / NT
; Author: ChiDragon
;
; ----------------------------------------------------------------------------


; ----------------------------------------------------------------------------
; End User Var's
; ----------------------------------------------------------------------------

$VDubText2 = "VirtualDub 1.9.10 - [" ;the end part is important in case another VDub is open in capture mode

; ----------------------------------------------------------------------------
; Prevent Duplicates From Running
; ----------------------------------------------------------------------------

$g_szVersion = "Trim Script"
If WinExists($g_szVersion) Then Exit ; It's already running
AutoItWinSetTitle($g_szVersion)


; ----------------------------------------------------------------------------
; Script Defaults
; ----------------------------------------------------------------------------

Opt ("MouseClickDelay", 10) ;10 milliseconds
Opt ("MouseClickDownDelay", 10) ;10 milliseconds
Opt ("MouseClickDragDelay", 1) ;250 milliseconds default
Opt ("MouseCoordMode", 0) ;1=absolute, 0=relative
Opt ("ExpandEnvStrings", 0) ; 0=don't expand, 1=do expand
Opt ("MustDeclareVars", 0) ; 0=no, 1=require pre-declare
Opt ("SendAttachMode", 0) ; 0=don't attach, 1=do attach
Opt ("SendCapslockMode", 1) ; 1=store and restore, 0=don't
Opt ("SendKeyDelay", 5) ; 5 milliseconds
Opt ("SendKeyDownDelay", 1) ; 1 millisecond
Opt ("TrayIconDebug", 1) ; 0=no info, 1=debug line info
Opt ("TrayIconHide", 0) ; 0=show, 1=hide tray icon
Opt ("WinDetectHiddenText", 0) ; 0=don't detect, 1=do detect
Opt ("WinSearchChildren", 1) ; 0=no, 1=search children also
Opt ("WinTitleMatchMode", 1) ; 1=start, 2=subStr, 3=exact, 4=...
Opt ("WinWaitDelay", 250) ; 250 milliseconds


; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

Dim $FrameArray

Func SelectFrame()
If Not WinExists ($VDubText2, "Frame") Then Exit
$Frame = ControlGetText ($VDubText2, "Frame", "Edit1")
;MsgBox (0, "", $Frame)
$FrameArray = StringSplit ($Frame, " ")
;ClipPut ($FrameArray[2] & @CRLF)
ClipPut ($FrameArray[2])
EndFunc

HotKeySet (";", "SelectFrame")

While 1
Sleep(100)
WEnd

EDIT: Possibly an easier way with AvsPmod, but it's more typing each time.

There is a hotkey to "Insert frame #". For me the F11 key (default?) didn't work for some reason. I changed it to F9 in Options -> Keyboard shortcuts and it works.

If you create a block comment at the end of your Avisynth script, you can place all the frame numbers there using this function and then copy and paste it to your text file or whatever after you're done.

/*
889
10342
983451
*/

The sequence of key presses required then is F9, ESC, ENTER. Escape is to toggle from the seek bar/preview display back to the script, and Enter is so that you don't just end up with a string of meaningless numbers mushed together on one line.

konstantin1
27th January 2016, 00:57
Thx, I didn't know about that editor, I thought it is only a simple text editor, but it has a preview pane too, and Python macros can be used. I think it is possible to code the frame number logging feature.

StainlessS
27th January 2016, 01:58
VD_EdKey, posted recently, here: http://forum.doom9.org/showthread.php?t=173010

Autoit source.

ChiDragon
27th January 2016, 02:07
Suggest use Avisynth "__END__" command at end of script (means 'everything from here onwards is COMMENT'), and position cursor afterwards to insert frame numbers there, can later copy and paste into a frames command file for avisynth use.
Learn something new every day!

StainlessS
27th January 2016, 02:22
I always forget whether its a double or triple underscore either side (its double, ie __END__).

There is also of course the /* and */ C style comments as well as # comment indicator.

konstantin1, would not prove too difficult to modify the VDM_Edkey scipt to insert CTRL/R (VDM insert range, VDMod editor has specific key to do this,
VD does not and would be at very least problematic to achieve the same thing). Any key (not used by VDMod main program) could be chosen as the user key, but need to send CTRL/R to VDMod editor. It should not be too difficult, everything necessary is already in the VDM_Edkey script.

EDIT: To save a little work, here list of keys used by VD (its kinda tedious to extract yourself)

FILE MENU:

CTRL/O Open Video file
F2 Re-Open Video file
SPACE Preview Input
ENTER Preview Filtered
F5 Preview Output From Start
F7 SaveAs AVI
SHIFT/F7 Save Old Format AVI
CTRL/W Close AVI
CTRL/SHIFT/F7 Queue Batch Save AVI
CTRL/L Load Processing Settings
CTRL/S Save Processing Settings
F4 Job Control
CTRL/Z Undo

EDIT MENU:
CTRL/Y ReDo
CTRL/X Cut
CTRL/C Copy
CTRL/V Paste
DELETE Delete
CTRL/D Clear Selection
CTRL/A Select ALL
HOME Set Selection Start
END Set Selection End

VIEW MENU:
F9 Toggle Input Input Video Pane
F10 Toggle Output Input Video Pane
SHIFT/F10 View decompressed Output
F8 Log
SHIFT/F8 Real-Time Profiler

GO MENU:
CTRL/LEFT Beginning
CTRL/RIGHT End
LEFT Previous frame
RIGHT Next Frame
SHIFT/LEFT Previous KeyFrame
SHIFT/RIGHT Next KeyFrame
ALT/LEFT Back 50 Frames
ALT/RIGHT Forward 50 Frames
PAGEUP Back 50 Frames
PAGEDOWN Forward 50 Frames
SHIFT/[ Prev Drop Frame
SHIFT/] Next Drop Frame
SHIFT/, Prev Range
SHIFT/. Next Range
[ Goto Selection Start
] Goto Selection End
CTRL/SHIFT/LEFT Goto Prev Scene
CTRL/SHIFT/RIGHT Goto Next Scene
CTRL/G Goto Frame

VIDEO MENU:
CTRL/F Filters
CTRL/R FrameRate
CTRL/P Compression
CTRL/1 Copy Source frame to ClipBoard
CTRL/2 Copy Output frame to ClipBoard

AUDIO MENU:
CTRL/I Interleaving
CTRL/N Conversion

HELP MENU:

F1 Help


#############################################################
#############################################################
#############################################################
PLAIN KEYS:
[ Goto Selection Start
] Goto Selection End
SPACE Preview Input
ENTER Preview Filtered
DELETE Delete
HOME Set Selection Start
END Set Selection End
LEFT Previous frame
RIGHT Next Frame
PAGEUP Back 50 Frames
PAGEDOWN Forward 50 Frames


CTRL KEYS:
CTRL/1 Copy Source frame to ClipBoard
CTRL/2 Copy Output frame to ClipBoard
CTRL/A Select ALL
CTRL/C Copy
CTRL/D Clear Selection
CTRL/F Filters
CTRL/G Goto Frame
CTRL/I Interleaving
CTRL/L Load Processing Settings
CTRL/N Conversion
CTRL/O Open Video file
CTRL/P Compression
CTRL/R FrameRate
CTRL/S Save Processing Settings
CTRL/V Paste
CTRL/W Close AVI
CTRL/X Cut
CTRL/Y ReDo
CTRL/Z Undo
CTRL/LEFT Beginning
CTRL/RIGHT End
CTRL/SHIFT/F7 Queue Batch Save AVI


FUNCTION KEYS:

F1 Help
F2 Re-Open Video file
F4 Job Control
F5 Preview Output From Start
F7 SaveAs AVI
F8 Log
F9 Toggle Input Input Video Pane
F10 Toggle Output Input Video Pane

SHIFT KEYS:
SHIFT/[ Prev Drop Frame
SHIFT/] Next Drop Frame
SHIFT/, Prev Range
SHIFT/. Next Range
SHIFT/LEFT Previous KeyFrame
SHIFT/RIGHT Next KeyFrame
SHIFT/F7 Save Old Format AVI
SHIFT/F8 Real-Time Profiler
SHIFT/F10 View decompressed Output


CTRL/SHIFT/LEFT Goto Prev Scene
CTRL/SHIFT/RIGHT Goto Next Scene
ALT/LEFT Back 50 Frames
ALT/RIGHT Forward 50 Frames

shekh
27th January 2016, 11:53
I think Blender has timeline markers and it is python scriptable. But I never used it.

StainlessS
5th February 2016, 03:03
Updated VD_Edkey to v1.00, includes Frame Range. here:- http://forum.doom9.org/showthread.php?t=173010