Here is some scripts I copied and modified from others. Many thanks to those who wrote and share the scripts so I can be much more productive.
Suppose you are a wedding video editor, you got 500 clips from 2 tapes. And you want to cut most clips into 10 or 5 second pieces. Now use this script, you can split all selected clips in just one click(You need to have Vegas 4.0d to run it):
---------------------
/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
//time intervals for split events.
var Interval = "00:10:00";
try
{
var IncTime : Timecode = new Timecode(Interval);
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;
evnt.Split(IncTime);
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
--------------------
OK, now your clips are all broken into pieces. You insert a new video track as the first track, and want to randomly put those pieces in a new order in that track, plus 1.5 second crossfade with each other. Using the following script, you just need to select some pieces, run the script, those pieces will be moved to the end of the first track(make sure that is a video track).
--------------------
/**
* Program: PutInFirstTrackEnd.js
* Description: This script will move selected events(except the one in first track) to
* the end of the first track. And automatically crossfade with the last event.
* Author: Philip
*
* Date: August 24, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
//time intervals for split events.
var playrate : double = 1;
var fadetime = new Timecode("00:00:01:15");
try
{
// step through all selected video events:
var FirstTrack : Track = Vegas.Project.Tracks.Item(0);
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
if( track.Index == 0) continue;
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;
evnt.Copy(FirstTrack,FirstTrack.Length-fadetime);
track.Events.Remove(evnt);
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
/**
* Finds the currently selected event. Searches all tracks and returns the first
* even that is selected or null if no event is selected
* (Taken from the SonicFoundry Scripting FAQ)
*/
function FindSelectedEvent() : TrackEvent
{
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd())
{
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd())
{
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if (evnt.Selected)
{
return evnt;
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}
return null;
}
------------------------
When you keep doing this, you find out that because the pieces are moved to
the first track, therefore you get a lot of empty place in other tracks. Don't worry, just select the track that has this problem, run the following script, now the whole track will be arranged neatly, no more empty places. (Don't select track 1 though.)
--------------------
/**
* Program:
* Description: This script will Delete Empty Space Between Events In Selected Tracks
* Author: Philip
*
* Date: August 27, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
//time intervals for split events.
var septime = new Timecode("00:00:00:01");
try
{
// step through all selected video events:
var FirstTrack : Track = Vegas.Project.Tracks.Item(0);
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
if( !track.Selected) continue;
var tracktime = new Timecode(0);
for (var evnt in track.Events) {
evnt.Start=tracktime;
tracktime = tracktime + evnt.Length+septime;
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
-----------------------
Alright, now you have all pieces put in first track. It's the time to slow down all the video and put some Video FX in them. Select the ones you want to add effects and run the following script.
------------------------
/**
* Program: AddEffectAndSlowPlay.js
* Description: This script will add a FX and change playrate to the selected event
* Author: Philip
*
* Date: August 24, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
// This is the full name of the effect plug-in you want to add.
var plugInName = "Sonic Foundry Color Corrector (Secondary)";
// This is the name of the preset you want. Set this to null if you
// want the default preset.
var presetName = "Boost Mids";
var playrate = 0.5;
try
{
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;
// Add FX
var fx = Vegas.VideoFX;
var plugIn = fx.GetChildByName(plugInName);
if (null == plugIn) {
throw "could not find a plug-in named: '" + plugInName + "'";
}
var effect = new Effect(plugIn);
evnt.Effects.Add(effect);
if (null != presetName) {
effect.Preset = presetName;
}
//Set playrate
evnt.AdjustPlaybackRate(playrate, 0);
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
------------------------
Finnally, the wedding video clips are all in places, it's time to do small adjustments and add music, transaction, titles, killer effects, etc... No more scripts needed, all the scripts here are just help you to build a barebone wedding MTV really quick (400 clips in about one hour) so you don't need to do those repetitive job that I had to do before discovering the true power of scripts.
Thank you Vegas Programmer, for making such a wonderful and powerful tool. And thank all the guys who post scripts here so I could copy and pirate :)
Suppose you are a wedding video editor, you got 500 clips from 2 tapes. And you want to cut most clips into 10 or 5 second pieces. Now use this script, you can split all selected clips in just one click(You need to have Vegas 4.0d to run it):
---------------------
/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
//time intervals for split events.
var Interval = "00:10:00";
try
{
var IncTime : Timecode = new Timecode(Interval);
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;
evnt.Split(IncTime);
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
--------------------
OK, now your clips are all broken into pieces. You insert a new video track as the first track, and want to randomly put those pieces in a new order in that track, plus 1.5 second crossfade with each other. Using the following script, you just need to select some pieces, run the script, those pieces will be moved to the end of the first track(make sure that is a video track).
--------------------
/**
* Program: PutInFirstTrackEnd.js
* Description: This script will move selected events(except the one in first track) to
* the end of the first track. And automatically crossfade with the last event.
* Author: Philip
*
* Date: August 24, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
//time intervals for split events.
var playrate : double = 1;
var fadetime = new Timecode("00:00:01:15");
try
{
// step through all selected video events:
var FirstTrack : Track = Vegas.Project.Tracks.Item(0);
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
if( track.Index == 0) continue;
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;
evnt.Copy(FirstTrack,FirstTrack.Length-fadetime);
track.Events.Remove(evnt);
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
/**
* Finds the currently selected event. Searches all tracks and returns the first
* even that is selected or null if no event is selected
* (Taken from the SonicFoundry Scripting FAQ)
*/
function FindSelectedEvent() : TrackEvent
{
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd())
{
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd())
{
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if (evnt.Selected)
{
return evnt;
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}
return null;
}
------------------------
When you keep doing this, you find out that because the pieces are moved to
the first track, therefore you get a lot of empty place in other tracks. Don't worry, just select the track that has this problem, run the following script, now the whole track will be arranged neatly, no more empty places. (Don't select track 1 though.)
--------------------
/**
* Program:
* Description: This script will Delete Empty Space Between Events In Selected Tracks
* Author: Philip
*
* Date: August 27, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
//time intervals for split events.
var septime = new Timecode("00:00:00:01");
try
{
// step through all selected video events:
var FirstTrack : Track = Vegas.Project.Tracks.Item(0);
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
if( !track.Selected) continue;
var tracktime = new Timecode(0);
for (var evnt in track.Events) {
evnt.Start=tracktime;
tracktime = tracktime + evnt.Length+septime;
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
-----------------------
Alright, now you have all pieces put in first track. It's the time to slow down all the video and put some Video FX in them. Select the ones you want to add effects and run the following script.
------------------------
/**
* Program: AddEffectAndSlowPlay.js
* Description: This script will add a FX and change playrate to the selected event
* Author: Philip
*
* Date: August 24, 2003
**/
import SonicFoundry.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;
// This is the full name of the effect plug-in you want to add.
var plugInName = "Sonic Foundry Color Corrector (Secondary)";
// This is the name of the preset you want. Set this to null if you
// want the default preset.
var presetName = "Boost Mids";
var playrate = 0.5;
try
{
// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;
// Add FX
var fx = Vegas.VideoFX;
var plugIn = fx.GetChildByName(plugInName);
if (null == plugIn) {
throw "could not find a plug-in named: '" + plugInName + "'";
}
var effect = new Effect(plugIn);
evnt.Effects.Add(effect);
if (null != presetName) {
effect.Preset = presetName;
}
//Set playrate
evnt.AdjustPlaybackRate(playrate, 0);
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
------------------------
Finnally, the wedding video clips are all in places, it's time to do small adjustments and add music, transaction, titles, killer effects, etc... No more scripts needed, all the scripts here are just help you to build a barebone wedding MTV really quick (400 clips in about one hour) so you don't need to do those repetitive job that I had to do before discovering the true power of scripts.
Thank you Vegas Programmer, for making such a wonderful and powerful tool. And thank all the guys who post scripts here so I could copy and pirate :)