The description of this script is given in the comments in its header below.
I created this because I couldn't find a way in Vegas to manage a huge number (400-600) of short clips that have to be condensed into a five minute music video. I needed a way to create a database from these clips.
Using this script here is my workflow: I took my video, and trimmed out all the "garbage," leaving several hundred short events on one track. This script helps me name these events, using regions, and do so in a consistent manner, using "tags" rather than having to type everything. Once the regions are all created and named, I render to a single, new AVI file. I then start a new project. I use the "Region View" in Vegas' Explorer to see and sort the regions I have created. I can then drag the appropriate regions from this one AVI file to my timeline. The only flaw in this workflow so far is that I can't really tell which clips have not yet been used.
Vegas could use a lot of work in the area of media management. Hopefully this is a small step in the right direction.
I created this because I couldn't find a way in Vegas to manage a huge number (400-600) of short clips that have to be condensed into a five minute music video. I needed a way to create a database from these clips.
Using this script here is my workflow: I took my video, and trimmed out all the "garbage," leaving several hundred short events on one track. This script helps me name these events, using regions, and do so in a consistent manner, using "tags" rather than having to type everything. Once the regions are all created and named, I render to a single, new AVI file. I then start a new project. I use the "Region View" in Vegas' Explorer to see and sort the regions I have created. I can then drag the appropriate regions from this one AVI file to my timeline. The only flaw in this workflow so far is that I can't really tell which clips have not yet been used.
Vegas could use a lot of work in the area of media management. Hopefully this is a small step in the right direction.
/**
* PURPOSE OF THIS SCRIPT:
*
* This script creates a region for every event on the selected track.
* As it creates each region, it lets you name that region using a dialog box.
* Each event is optionally previewed (a sample of ten frames across
* the entire event) for five seconds prior to naming.
* You can re-preview the event as often as you like.
*
* Because of the limitations of enumeration, there is no easy way to
* go back to a previous event. However, if you cancel the script,
* it will skip over any existing regions that you already created so
* you can continue where you left off.
*
* Region naming is done with ListBoxes that contain fixed text strings.
* You can also enter additional text using the text box.
* A region number is appended to each region name to ensure unique names.
*
* The "Enter" key "click" the next button no matter where you are in the
* dialog box.
*
* Written By: John Meyer
* November 6, 2003
* Tested on Windows XP Pro, SP1, with Vegas 4.0d
*
**/
import System;
import System.IO;
import System.Collections;
import System.Text;
import System.Windows.Forms;
import SonicFoundry.Vegas;
import System.Threading;
var evnt : TrackEvent;
var myRegion : Region;
var i : Double;
var dLength : Double;
var dStart : Double;
var RegionName : String;
var RegionNumber;
var PreviewVideo;
try {
RegionNumber = 1;
PreviewVideo = 1;
//Find the selected event
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
var eventEnum = new Enumerator(track.Events);
// Go through each event on the selected track.
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
dLength = evnt.Length.ToMilliseconds();
dStart = evnt.Start.ToMilliseconds();
if (!RegionExist (dStart,dLength) ) { // Only proceed if no region
// Preview the video, but only if preview is enabled in the dialog check box.
if (PreviewVideo) {
for (i = 0; i < 10; i++) {
Vegas.Cursor = evnt.Start + new Timecode(0.1 * i * dLength);
Thread.Sleep(250); // Change this to change playback speed
Vegas.UpdateUI();
}
}
// Get region information through the dialog box defined below.
var dialog = new MainDialog("", 0, RegionNumber, PreviewVideo);
var dialogResult = dialog.ShowDialog();
// Proceed if the "Next" button was pressed.
if (System.Windows.Forms.DialogResult.OK == dialogResult) {
// Get the region name from the dialog box values.
RegionName = dialog.regionBox1.Text+", "+dialog.regionBox2.Text;
// Create the region name from the Listbox, textbox, and region number
if (dialog.RegionNameBox.Text != " ") {
RegionName = RegionName + " " + dialog.RegionNameBox.Text + " " + RegionNumber.ToString();
}
else {
RegionName = " " + RegionName+RegionNumber.ToString();
}
// Insert a region "over" this event.
myRegion = new Region(evnt.Start,evnt.Length,RegionName);
Vegas.Project.Regions.Add(myRegion);
// Move to the next event, and increment the region number
eventEnum.moveNext();
RegionNumber++;
}
else {
if (System.Windows.Forms.DialogResult.Cancel == dialogResult) {
throw "Operation cancelled";
}
}
PreviewVideo = dialog.PreviewBox.Checked ? 1 : 0;
}
else { // Else if !RegionExist
eventEnum.moveNext(); // If region already existed, simply go to the next event
RegionNumber++;
}
}
}
catch (e) {
MessageBox.Show(e);
}
// End Main Program
//
// ---------------------------------
// Begin functions
function FindSelectedTrack() : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}
//-------------------------------------------------------
// Checks if a region already exists for this event
function RegionExist (dStart,dLength) : boolean {
var markerEnum = new Enumerator(Vegas.Project.Regions);
while (!markerEnum.atEnd()) {
var Region = markerEnum.item();
var RegionLength = Region.Length.ToMilliseconds();
var RegionStart = Region.Position.ToMilliseconds();
if ( (dLength == RegionLength) && (dStart == RegionStart) ) {
return 1;
}
markerEnum.moveNext();
}
return 0;
}
//-------------------------------------------------------
// Form subclass that is the dialog box for this script
class MainDialog extends Form {
var RegionNameBox;
var regionBox1;
var regionBox2;
var PreviewBox;
function MainDialog(RegionName, region, RegionNumber, PreviewVideo) {
this.Text = "Create Regions";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;
this.Width = 500;
var buttonWidth = 80;
var label = new Label();
label.AutoSize = true;
label.Text = "Region Name 1:";
label.Left = 10;
label.Top = 15;
Controls.Add(label);
regionBox1 = new ListBox(); // Change to ComboBox() to permit random text entry
regionBox1.Left = label.Right;
regionBox1.Top = label.Top-5; // Note how positions are relative to other objects
regionBox1.Width = 200;
regionBox1.Height = 170;
regionBox1.DropDownWidth = 200;
regionBox1.Items.Add("Alison"); // *********************************** //
regionBox1.Items.Add("Elise"); // //
regionBox1.Items.Add("Jackie"); // Change the names to the ones //
regionBox1.Items.Add("Jamie"); // you want. You can also simply //
regionBox1.Items.Add("Katie"); // add or delete the lines here //
regionBox1.Items.Add("Larissa"); // to get the number of entries //
regionBox1.Items.Add("Michelle"); // you want. //
regionBox1.Items.Add("Natasha"); // //
regionBox1.Items.Add("Quinnie"); // //
regionBox1.Items.Add("Tyler"); // *********************************** //
regionBox1.SelectedIndex = region;
Controls.Add(regionBox1);
var label = new Label();
label.AutoSize = true;
label.Text = "Region Name 2:";
label.Left = 10;
label.Top = regionBox1.Bottom + 20;
Controls.Add(label);
regionBox2 = new ListBox(); // Change to ComboBox() to permit random text entry
regionBox2.Width = 200;
regionBox2.Height = 130;
regionBox2.DropDownWidth = 200;
regionBox2.Left = label.Right;
regionBox2.Top = label.Top-5;
regionBox2.Items.Add("Hit"); // Add or delete these lines (same as above)
regionBox2.Items.Add("Dig");
regionBox2.Items.Add("Serve");
regionBox2.Items.Add("Set");
regionBox2.Items.Add("Group");
regionBox2.Items.Add("Unusual");
regionBox2.Items.Add("Warmup");
regionBox2.SelectedIndex = region;
Controls.Add(regionBox2);
RegionNameBox = addTextControl("Region Suffix: ", 10, 300, regionBox2.Bottom + 16, "");
var label = new Label();
label.AutoSize = true;
label.Text = "Region Number: " + RegionNumber.ToString();
label.Left = 10;
label.Top = RegionNameBox.Bottom + 20;
Controls.Add(label);
PreviewBox = new CheckBox();
PreviewBox.Left = 10;
PreviewBox.Width = 160;
PreviewBox.Top = label.Bottom + 15;
PreviewBox.Text = "Preview Video";
PreviewBox.Checked = PreviewVideo != 0;
Controls.Add(PreviewBox);
var buttonTop = PreviewBox.Top;
var cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Left = this.Width - (1*(buttonWidth+10));
cancelButton.Top = regionBox1.Top;
cancelButton.Height = cancelButton.Font.Height + 12;
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
CancelButton = cancelButton;
Controls.Add(cancelButton);
var NextButton = new Button();
NextButton.Text = "Next";
NextButton.Left = this.Width - (1*(buttonWidth+10));
NextButton.Top = buttonTop;
NextButton.Width = buttonWidth;
NextButton.Height = NextButton.Font.Height + 12;
NextButton.DialogResult = System.Windows.Forms.DialogResult.OK;
AcceptButton = NextButton; // The Enter key will automatically activate this button.
Controls.Add(NextButton);
var ReplayButton = new Button();
ReplayButton.Text = "Replay";
ReplayButton.Left = this.Width - (2*(buttonWidth+10));
ReplayButton.Top = buttonTop;
ReplayButton.Width = buttonWidth;
ReplayButton.Height = ReplayButton.Font.Height + 12;
ReplayButton.DialogResult = System.Windows.Forms.DialogResult.Retry;
Controls.Add(ReplayButton);
var titleHeight = this.Height - this.ClientSize.Height;
this.Height = titleHeight + NextButton.Bottom + 20;
} // End function MainDialog
//
// -------------------------------------
function addTextControl(labelName, left, width, top, defaultValue) {
var label = new Label();
label.AutoSize = true;
label.Text = labelName + ":";
label.Left = left;
label.Top = top + 4;
Controls.Add(label);
var textbox = new TextBox();
textbox.Multiline = false;
textbox.Left = label.Right;
textbox.Top = top;
textbox.Width = width - (label.Width);
textbox.Text = defaultValue;
Controls.Add(textbox);
return textbox;
}
} // End class MainDialog