PDA

View Full Version : Batch_mkv2vob: A mkv2vob wrapper for batch processing (v0.2.1)


natronicus
14th February 2008, 00:37
Hello all,

As mkv2vob does not have a batch processing mode, I hunted the internet to find a macro/scripting language that would automate this process for us. I found AutoHotKey (www.autohotkey.com).

The attached zip file contains the autohotkey script (so you can review/improve/modify the code if you wish) as well as a compiled .exe file for people who just want it to work.

When run, the script will:

1. Find mkv2vob. It looks in the same directory as the script first, but if it isn't found it will prompt you for the location of mkv2vob.
2. Ask you where your .mkv files are. It will recursively search through this folder and all subfolders for *.mkv files and queue them for processing.
3. Ask you where you would like your output .vob files located. (They will all be placed in the same folder. If you have two files in different folders with the same name, the first will be overwritten by the second. E.g., .\videoFile.mkv and .\directory\videoFile.mkv are two different files with the same name. Only one file will remain in the output file named videoFile.vob.)
4. Now that it has all the information needed, it will loop through the found files, running mkv2vob and supplying the input and output files as needed.

v 0.2.1 02/13/08: Added traytip and icon's tooltip to identify progress. Removed some unneeded variables.
v 0.2.0 02/13/08: Initial release.

The script file:
; Batch_mkv2vob.ahk v0.2.1 by natronicus
; Last updated: 02/13/08

; This script utilizes the macro/scripting language autohotkey. Visit
; www.autohotkey.com for documentation, example scripts, etc.

; This script automates usage of the mkv2vob program by 3r1c @ doom9. It recursively
; searches through a specified folder, generating a list of all .mkv files present,
; generates the output list of filenames (the previous list with .vob appended), starts
; mkv2vob with the first file, waits for the "Remuxing Complete" message, and
; starts over.

; This initial release is fairly "stupid" and does not handle errors at all. If a
; transcode fails, the script will hang. There is no resume if you cancel it
; halfway through. It will overwrite filenames without prompting.

; If the script hangs, right click the task bar icon and manually end the script. I did
; not extensively test this script. It likely has other issues with it that will cause
; it to fail.

; v 0.2.1 02/13/08: Added traytip and icon's tooltip to identify progress. Removed some
; unneeded variables.
; v 0.2 02/13/08: Initial release.

;-- Main Routine
gosub ObtainFolderLocs
gosub ObtainFileList
MsgBox, 4, Continue? (Press YES or NO), Files to convert:`n`n%FullPathFileList%`nContinue?
IfMsgBox Yes
gosub ProcessFileList
;MsgBox, ProcessFileList
Return

ObtainFolderLocs:
Mkv2vobLoc = ; init to null
FolderMKV =
FolderOutput =
IfExist, mkv2vob.exe
Mkv2vobLoc = %A_WorkingDir%\mkv2vob.exe
else
FileSelectFile, Mkv2vobLoc, 3,, Please select the location of mkv2vob.exe, mkv2vob executable (mkv2vob.exe)
FileSelectFolder, FolderMKV,, 3, Please select the folder where your .mkv files are located.
FileSelectFolder, FolderOutput, *%FolderMKV%, 3, Please select the folder where you would like the output .vob files placed.
Return

ObtainFileList:
; Obtain a file listing of .mkv files.
Loop, %FolderMKV%\*.mkv,, 1 ; The 1 turns on recursion
{
FullPathFileList = %FullPathFileList%%A_LoopFileFullPath%`n ; `n is the new line char
MkvCount = %A_Index%
}
Return

UpdateTray:
TrayTip, Batch mkv2vob processing..., Processing %NumFileConverting% of %MkvCount%.`n%varFileName%
SetTimer, RemoveTrayTip, 5000
Return

RemoveTrayTip:
SetTimer, RemoveTrayTip, Off
TrayTip
return

ProcessFileList:
; Loop through the file listing
FileOutputListing =
Loop, parse, FullPathFileList, `n ; We will use new line as the delimiter
{
if A_LoopField = ; Ignore the blank item at the end of the list.
continue

NumFileConverting = %A_Index%

varFileToConvert = %A_LoopField%
SplitPath, A_LoopField,varFileName,,, varFileNameNoExt
varFileOutput = %FolderOutput%\%varFileNameNoExt%.vob
FileOutputListing = %FileOutputListing%%varFileOutput%`n

gosub UpdateTray
Menu, tray, Tip, Batch mkv2vob processing... `n`nCurrently on %varFileName% (%NumFileConverting% of %MkvCount%)
gosub BatchMkv2vob
MsgBox, BatchMkv2vob process.

}
;ListVars
MsgBox,, %NumFileConverting% file(s) converted!, %FileOutputListing%
Return

BatchMkv2vob:
; Launch mkv2vob
Run %Mkv2vobLoc%

; Wait for it to start, activate the window, input varFileToConvert
WinWait, Select your MKV file,
IfWinNotActive, Select your MKV file, , WinActivate, Select your MKV file,
WinWaitActive, Select your MKV file,
Send, %varFileToConvert%{ENTER}

; Input varFullPathOutput
WinWait, Select destination VOB file,
IfWinNotActive, Select destination VOB file, , WinActivate, Select destination VOB file,
WinWaitActive, Select destination VOB file
Send, %varFileOutput%{ENTER}

; Select automatic transcoding.
WinWait, Conversion Options,
IfWinNotActive, Conversion Options, , WinActivate, Conversion Options,
WinWaitActive, Conversion Options,
MouseClick, left, 98, 137

WinWait, mkv2vob by 3r1c, Remuxing Complete
IfWinNotActive, mkv2vob by 3r1c, , WinActivate, mkv2vob by 3r1c,
WinWaitActive, mkv2vob by 3r1c,
MouseClick, left, 77, 95
Return


Click here (http://www.natronicus.com-a.googlepages.com/batch_mkv2vob_v0.2.1.zip) to download batch_mkv2vob_v0.2.1.zip containing:

batch_mkv2vob_v0.2.1.ahk
batch_mkv2vob_v0.2.1.exe

Atak_Snajpera
14th February 2008, 01:24
Could you do something similar for TSRemux (BluRay Structure) ?

natronicus
14th February 2008, 02:25
Could you do something similar for TSRemux (BluRay Structure) ?

Sorry, I don't use it and don't have TSRemux source files handy to test. I took a quick look at the tool and it seems to have several options requiring interaction from the user. I would have to build in logic to ask those preferences (a pain) or know what preferences were most common and just code those (which I don't know).

You're welcome to use my script as a starting point and do it yourself, however. The only subroutine you would have to change is the "BatchMkv2vob:" section.

AutoHotKey comes with a script creating tool called "AutoScriptWriter" that records what you do with the mouse, keyboard, etc and converts into AHK script commands. You could almost drop those directly over the BatchMkv2vob section and it'd be done.

I tried to comment the script quite a bit to tell you what it's doing; feel free to contact me if you have any questions.

natronicus
14th February 2008, 04:49
On second thought, are you just wanting something that can expose all of the options to the command line? That would be easy.

If you're wanting to do this in order to tie it in to RipBot264 just let me know what options you're interested in and I'll throw it together.

If you can send me / make available a sample input file for testing I would appreciate that as well.

Of course, the correct way to do it is to get the C# source from the author and code it in correctly. Doing it with autohotkey will force it to be reliant on the GUI layout. If/when it changes as TSRemux is developed, it'll break the script.

Anyway, as this is off the topic of mkv2vob, send me a PM if you would like to continue discussion.

Regards,
n