Created
August 22, 2021 20:58
-
-
Save CaptainZidgel/47a17742ea2a648272478f47b95c4af3 to your computer and use it in GitHub Desktop.
Creates jobs for vdub from a folder of lawena output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://www.virtualdub.org/docs/vdscript.txt | |
#Open vdub>File>Job Control>File>Load job list badda bing badda boom | |
import os | |
import re | |
frame_group_pattern = re.compile('([a-z]\d)_(\d+)\.tga') | |
jf_out = input("This file should be saved to...>") | |
in_dir = input("Frames In Dir >") | |
out_dir = input("AVI Out Dir >") | |
limit = input("Limit to first x jobs: <0 for no limit> >") | |
batch_dir = os.listdir(in_dir) | |
jobs = {} | |
for filename in batch_dir: #files can be frames or wavs | |
match = re.match(frame_group_pattern, filename) | |
if match: | |
jobs[match.group(1)] = match.group(2) #am i stupid? is there no easier way to do this? what is wrong with me? | |
with open(jf_out, "w+") as f: | |
f.write("""// VirtualDub job list (Sylia script format) w/ ZidScript | |
// This is a python generated script for a terribly written 'scripting interface' for an old program - use at your own risk | |
// | |
// $numjobs {} | |
// | |
""".format(len(jobs))) | |
for signifier,highest in jobs.items(): | |
norm_input = os.path.join(in_dir, signifier + "_0000.tga").replace("\\", "\\\\") #lol | |
norm_output = os.path.join(out_dir, signifier + "_0000.avi").replace("\\", "\\\\") | |
doubl_audio_input = os.path.join(in_dir, signifier + "_.wav").replace("\\", "\\\\") | |
doubl_input = norm_input #i dont think you actually need this anymore if im using double slashes for norm anyway? sorry i didnt clean up the code before publishing i just know it works and dont want to lose my file | |
doubl_output = norm_output | |
frame_count = int(highest) + 1 | |
f.write(f'''// $job "Job {signifier[1]}" | |
// $input "{norm_input}" | |
// $output "{norm_output}" | |
// $state 0 | |
// $start_time 00000000 00000000 | |
// $end_time 00000000 00000000 | |
// $script | |
VirtualDub.Open("{doubl_input}","",0); | |
VirtualDub.audio.SetSource("{doubl_audio_input}", ""); | |
VirtualDub.audio.SetMode(0); | |
VirtualDub.audio.SetInterleave(1,500,1,0,0); | |
VirtualDub.audio.SetClipMode(1,1); | |
VirtualDub.audio.SetEditMode(1); | |
VirtualDub.audio.SetConversion(0,0,0,0,0); | |
VirtualDub.audio.SetVolume(); | |
VirtualDub.audio.SetCompression(); | |
VirtualDub.audio.EnableFilterGraph(0); | |
VirtualDub.video.SetInputFormat(0); | |
VirtualDub.video.SetOutputFormat(7); | |
VirtualDub.video.SetMode(3); | |
VirtualDub.video.SetSmartRendering(0); | |
VirtualDub.video.SetPreserveEmptyFrames(0); | |
VirtualDub.video.SetFrameRate2(1,0,1); | |
VirtualDub.video.SetIVTC(0, 0, 0, 0); | |
VirtualDub.video.SetCompression(); | |
VirtualDub.video.filters.Clear(); | |
VirtualDub.audio.filters.Clear(); | |
VirtualDub.subset.Clear(); | |
VirtualDub.subset.AddRange(0,{frame_count}); | |
VirtualDub.video.SetRange(); | |
VirtualDub.project.ClearTextInfo(); | |
// -- $reloadstop -- | |
VirtualDub.SaveAVI("{doubl_output}"); | |
VirtualDub.audio.SetSource(1); | |
VirtualDub.Close(); | |
// $endjob | |
// | |
//-------------------------------------------------- | |
''') | |
if limit != 0 and signifier[1] == limit: | |
break | |
f.write("// $done") | |
#please submit all questions to the RUBBISH BIN and also the comments I will be happy to answer them |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment