/**
*
* The script will use exactly one frame from each event on the selected video track,
* and delete everything else. All gaps between events will be eliminated,
* resulting in a single smooth movie.
*
* Each event should be from a discrete, separate video file (i.e., make sure
* "Enable DV Scene Detection" is checked in Vegas Capture).
*
* The script could probably be modified to work on a single file that has been
* broken up into events, but I didin't have time to figure out how to do this, and
* I figure most time lapse captures would be captured into separate files for each clip
*
* The main use envisioned for this script is the creation of true time
* lapse movies from the multiple one-second clips that many camcorders
* record when put in "time-lapse" mode.
*
* A video track must be selected. If an audio track is selected, nothing happens.
* Only the first selected track is affected. If more than one video track is selected,
* subsequent tracks are ignored.
*
* This script uses the LAST frame(s) in the event on the theory that the first frame from
* a time lapse capture may be slightly corrupted from tape startup glitches.
*
* Written By: John Meyer
* Written: October 22, 2003
*
**/
import System;
import System.IO;
import System.Windows.Forms;
import SonicFoundry.Vegas;
/**
**************************************************************************
* Start of main program *
**************************************************************************
**/
try {
//Change the next line to set the number of frames to keep.
var SaveFrames : Timecode = new Timecode("00:00:00:01"); //This is 1 frame.
var DeleteTime : double = SaveFrames.ToMilliseconds(); // Convert frames to milliseconds.
//Global declarations
var dStart : Double;
var trackEnum : Enumerator;
var evnt : TrackEvent;
//Use the FindSelectedTrack() function to find the first selected track.
var track = FindSelectedTrack();
var eventEnum = new Enumerator(track.Events);
if (track.IsVideo()) { // Proceed only if selected track is a video track.
TrimEvent(); // Function that "trims" event down to "n" frames
}
Vegas.UpdateUI();
} catch (e) {
MessageBox.Show(e);
}
// End of main program
// ***********************************************************************
// Beginning of functions
/**
**************************************************************************
* This function finds the first selected track *
**************************************************************************
**/
function FindSelectedTrack() : Track {
trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}
/**
***************************************************************************
* The following function trims all events on the selected track *
* by "n" (usually 1) frame(s). Only the LAST n frames in the event remain.*
***************************************************************************
**/
function TrimEvent() {
dStart = 0; // Initialize the starting point.
//Go through each event on the track.
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item()); // Get the next event on the timeline.
evnt.AdjustStartLength(new Timecode(dStart), new Timecode(DeleteTime), true);
dStart = evnt.Start.ToMilliseconds()+ DeleteTime; // Next event will start at end of this event.
eventEnum.moveNext(); // Go to next event on this timeline.
}
return null;
}
Time Lapse Script (Delete all but n frames from each event)
johnmeyer
wrote on 10/22/2003, 1:10 PM