Vegas 7.0 Script

Automated 24p Workflow using DGIndex and VirtualDubMod


What is this script?

There has been a lot of discussion on some of the video forums regarding the 24p pulldown removal issues with the Canon HV20. Since the HV20 doesn't put flags on the frames, most NLE's are not able to properly remove the pulldown. Farnsworth and Mike Dulay were able to put together some batch files and perl scripts to help automate some of the manual workflow using free tools such as DGIndex and VirtualDub to remove the pulldown. There were sill a few manual steps involved, so I decided to try my hand at a Vegas script to fully automate the workflow.

To understand what tools you will need in addition to this script, please refer to the following threads:
http://www.dvinfo.net/conf/showthread.php?t=92893 and  http://hv20.com/showthread.php?t=218

All my script does is copy your selected video files from your selected video track in the timeline to a "working directory" (for safety) and then runs DGIndex and VirtualDub against the file to remove the pulldown. For it to work, you simply specify a safe working directory (ideally a new empty directory with sufficient space to perform the file copies and output rendering), the path to DGIndex and VirtualDub and the AVI Synth template file to use. The script can automatically calculate any required audio delay based on the output template file created by DGIndex. You can also have the script create a new 24p vegas project and video track and place the output file from VirtualDub into the timeline, where you can recompress and re-render to a file which more suits your needs. Additionally, you can specify the compression method that you want VirtualDub to use when creating the final output file. I've provided some basic templates but you can create your own custom ones to work as you see fit.

IMPORTANT NOTES:

Right now, it will process the whole file represented by each event on the timeline
. It ignores clips, markers and all of that. I just grab the VideoEvent and get the underlying media file path and will operate against the entire file. As a result, it's best to just test this with a single track and a single video on the track.

Downloading the Script:
Right now I'd consider this script as a BETA script. I'm not responsible if you use it and do yourself any harm (refer to the section on "cleaning the working folder" down below). If you download and run this, I assume no responsibility, even if it works perfectly!

You can grab the Script DLL here. Just save the file to your vegas script folder and then your off and running. Make sure you read those threads earlier for the "accessory" free apps that this script uses. Without those applications, this script really doesn't do a whole lot.


Source Code:
I will be putting the source code up for anybody who wants it later this week. I just need to finish doing some commenting in the code first.


Help and Information

Here are a couple of screen caps of the script being executed from Vegas 7.0. Below the images is a list of the different options that are available and what you can do.

General Tab
Working Directory Specifies the directory that will be used by the script to copy the video files (from your timeline). This is the directory where all work will be performed and the output files from DGIndex and Virtual Dub will be placed.
DG Index Path Specifies the full path and file name to the DGIndex.exe application on your machine.
Virtual Dub Path Specifies the full path and file name to the VirtulDubMod.exe application on your machine. I have tested this script only with VirtualDubMod and not VirtualDub (regular).
AVS Template Specifies the full path and file name of the AVI Synth Template file which will be used by DGIndex and VirtualDub.
Calculate Audio Delay Specifies whether the script will parse the AVS file created by DGIndex to determine any required audio delay.
Create 24p Vegas Project Specifies whether a new 24p Vegas project will be created after VirtualDub has completed rendering the new file. The new video file will then be placed into the timeline.
Compression Specifies the compression (or really the whole job script) for VirtualDub. You can choose from one of the "presets" or create your own custom job script. See notes at the bottom of the page.
Edit ... Available only when using a custom compression. This allows you to enter the script information that will be used by VirtualDub during processing. See the bottom of the page.
Preview ... The script definitions for Virtual Dub are stripped of the calls for .Open, .subset, .Close and .SaveAVI. These are added by my script automatically. Preview lets you see the script more or less how it's passed to Virtual Dub.
Close Closes the script dialog.
Run Executes the script workflow. If this button is disabled, check the status bar at the bottom of the page to see what setting has a problem.
Clean WARNING: Clean will delete ALL files in the working directory. If you do this and delete things you didn't want to delete, it's not my fault. I warned you!
Load ... Loads a script template that will update the General Tab with information that you previously saved using the Save ... button.
Save ... Saves all of the information on the General Tab to an XML file which you can use to later load and execute. This does not apply to the video files tab.


Video Files Tab
Video Files Displays the list of video files that are on the selected video track in Vegas. Place a check next to each of the files which you want to process.


Working With VirtualDub Job Scripts: Here is some information about the VirtualDub Script API http://www.virtualdub.org/docs/vdscript.txt. It is a good resource to use. Some caveats about these .SYL files and how you need to create them in my script editor. Firstly, I automatically will add the calls for .Open, .subset, .Close and .SaveAVI. If you create a custom script, DO NOT put those calls in there. Only give me the script information between those calls. below is an example SYL file generated by my script. In this case, the first line and last 4 lines are what is added by my script. In a custom script, you would add everything between those lines. You can use the VirtualDub UI to generate this file as well, just setup your compression methods to suit your tastes and the click File->Save As but instead of saving, tell it to create a job instead. Then you can look at the Job list and export that to disk, where you can grab the content required to give to my script. Ideally, I could pop up those same dialogs, but that would take more time than I have right now for this. Maybe in a later release I'll allow for that though... VirtualDub.Open("C:\\Tools\\Working\\Short0001_.avs", "", 0); VirtualDub.RemoveInputStreams(); VirtualDub.stream[0].SetSource(0x73647561,0); VirtualDub.stream[0].DeleteComments(1); VirtualDub.stream[0].AdjustChapters(1); VirtualDub.stream[0].SetMode(0); VirtualDub.stream[0].SetInterleave(1,500,1,0,0); VirtualDub.stream[0].SetClipMode(1,1); VirtualDub.stream[0].SetConversion(0,0,0,0,0); VirtualDub.stream[0].SetVolume(); VirtualDub.stream[0].SetCompression(); VirtualDub.stream[0].EnableFilterGraph(0); VirtualDub.stream[0].filters.Clear(); VirtualDub.video.DeleteComments(1); VirtualDub.video.AdjustChapters(1); VirtualDub.video.SetDepth(24,24); VirtualDub.video.SetMode(3); VirtualDub.video.SetFrameRate(0,1); VirtualDub.video.SetIVTC(0,0,-1,0); VirtualDub.video.SetRange(0,0); VirtualDub.video.SetCompression(0x64686663,0,10000,0); VirtualDub.video.SetCompData(20,"AAAAAAIAAAAAAAAAAQAAAAAAAAA="); VirtualDub.video.filters.Clear(); VirtualDub.subset.Clear(); VirtualDub.subset.AddRange(0, 547); VirtualDub.SaveAVI("C:\\Tools\\Working\\Short0001.avi"); VirtualDub.Close();