Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro need to insert something between each clip

  • need to insert something between each clip

    Posted by Bill Clotz on April 8, 2011 at 9:19 pm

    I’m sure this probably requires a script, but if someone could give me some pointers about what I need to do, I might be able to write it myself (if there isn’t already something like this available).

    Basically, I have about 100 clips on a single track, back to back.
    I want to insert a gap of a certain length between each of those clips.
    Then, on another track, I want to place a clip at each of the gaps.

    I just can’t really find any tutorials or anything on scripting, so I’m not sure how to get started. I looked at the api and there is lots of stuff, and I’m not sure what I need to be looking for.

    Mithun Kumar replied 11 years, 7 months ago 6 Members · 6 Replies
  • 6 Replies
  • Rob Franks

    April 8, 2011 at 11:50 pm

    Edward Troxel’s website (JetDV) has lots of free scripts.

    Here’s one for gaps:

    /**
    * Program: AddGaps&Overlaps.js
    *
    * Description: This script will add a gap between all events on SELECTED tracks
    * in the input dialog box you should enter gap length in form of
    * “hh:mm:ss.ff” or input a number of frames.
    * First event on each track is placed at time “00:00:00.00”
    *
    * TIP: if you enter minus (-) before gap length, you’ll get overlaps
    * instead of gaps 🙂
    *
    * Written for: Vegas 6
    *
    * Author: Kamac kamac@email.si
    *
    * Version: 2.0
    * Date: July 5, 2005
    *
    * Change Log:
    * 2.0 (July 5, 2005): – fixed bugs in version 1.0, which didn’t work in case when any
    * event was moved so far right, that it began after the start of
    * next event. I made a workaround with help of temporary track;
    * all events are first moved to this temporary track with wanted
    * gaps and then moved back to original track. Temporary track is
    * then deleted. All this is done for all selected tracks.
    *
    **/

    import Sony.Vegas;
    import System.Windows.Forms;

    var StartTime : Timecode = new Timecode(“00:00:00.00”); // starting time of first event on each track
    var Gap : Timecode = new Timecode(“00:00:01.00″); // default gap length
    var evnt : TrackEvent;

    try
    {
    var dialog = new InputDialog(); // show the dialog
    dialog.eventTextBox.Text = Gap.ToString(); // fill the dialog with default Gap length
    if (DialogResult.OK == dialog.ShowDialog())
    {
    Gap = dialog.getGapLength();
    for (var track in Vegas.Project.Tracks)
    { // step through all project tracks and work on selected ones
    if( !track.Selected) continue;
    if(track.MediaType==”Video”)
    {
    var trackTemp = new VideoTrack(1, “Temp”); // create new video track
    };
    if(track.MediaType==”Audio”)
    {
    var trackTemp = new AudioTrack(1, “Temp”); // create new audio track
    };
    Vegas.Project.Tracks.Add(trackTemp); // add temporary track

    var tracktime = StartTime;
    var eventEnum = new Enumerator(track.Events);
    while (!eventEnum.atEnd())
    { // move all events from current track to temporary track with given gaps between them
    evnt = TrackEvent(eventEnum.item());
    evnt.Track = trackTemp; // move event to temp track
    evnt.Start = tracktime; // set event’s start time
    tracktime = tracktime + evnt.Length + Gap;
    eventEnum.moveFirst(); // always use first event on current track, because when
    // you move the first event to temporary track, what was
    // previously second event on current track, becomes first!
    }
    var eventEnumTemp = new Enumerator(trackTemp.Events);
    while (!eventEnumTemp.atEnd())
    { // move all events back to “source track”
    evnt = TrackEvent(eventEnumTemp.item());
    evnt.Track = track
    eventEnumTemp.moveFirst(); // always use first event on current track (look above for reason)
    }
    Vegas.Project.Tracks.Remove(trackTemp); // remove temporary track
    Vegas.UpdateUI(); // redraw Vegas interface
    }
    }
    }//try

    catch (errorMsg)
    { // Error handler
    MessageBox.Show(errorMsg, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error);
    }

    /************************************************
    * Dialog: Input dialog for gap lengths
    ************************************************/
    class InputDialog extends Form
    {
    var label1 : Label;
    var eventTextBox : TextBox;
    var cancelButton : Button;
    var okButton : Button;

    function InputDialog()
    {
    this.okButton = new Button();
    this.cancelButton = new Button();
    this.label1 = new Label();
    this.eventTextBox = new TextBox();
    this.SuspendLayout();
    //
    // eventTextBox
    //
    this.eventTextBox.Location = new System.Drawing.Point(100, 17);
    this.eventTextBox.Name = “eventTextBox”;
    this.eventTextBox.Size = new System.Drawing.Size(80, 20);
    this.eventTextBox.TabIndex = 1;
    this.eventTextBox.Text = “00:00:00.00”;
    //
    // okButton
    //
    this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    this.okButton.Location = new System.Drawing.Point(24, 50);
    this.okButton.Name = “okButton”;
    this.okButton.TabIndex = 2;
    this.okButton.Text = “OK”;
    //
    // cancelButton
    //
    this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    this.cancelButton.Location = new System.Drawing.Point(120, 50);
    this.cancelButton.Name = “cancelButton”;
    this.cancelButton.TabIndex = 3;
    this.cancelButton.Text = “Cancel”;
    //
    // label1
    //
    this.label1.Location = new System.Drawing.Point(30, 20);
    this.label1.Name = “label1”;
    this.label1.Size = new System.Drawing.Size(70, 16);
    this.label1.TabIndex = 4;
    this.label1.Text = “Gap Length:”;
    //
    // Form
    //
    this.AcceptButton = this.okButton;
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.CancelButton = this.cancelButton;
    this.ClientSize = new System.Drawing.Size(220, 90);
    this.ControlBox = false;
    this.Controls.Add(this.eventTextBox);
    this.Controls.Add(this.label1);
    this.Controls.Add(this.cancelButton);
    this.Controls.Add(this.okButton);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    this.MinimizeBox = false;
    this.Name = “Form”;
    this.StartPosition = FormStartPosition.CenterScreen;
    this.Text = “Set Gap (negative for OVERLAP!)”;
    this.ResumeLayout(false);
    }

    // Returns the event length as a timecode
    function getGapLength()
    {
    return new Timecode(eventTextBox.Text);
    }
    }

  • Aleksey Tarasov

    April 9, 2011 at 8:42 am

    Yes, scripts can help you. The first one can create gaps for you (such as already mentioned by Rob). Another one can create markers at the beginning of each gap, and the third on can place your clips at those markers. All these tasks can be easily implemented with scripting plug-ins like Vegasaur or similar.

  • John Rofrano

    April 9, 2011 at 2:47 pm

    Yea, you can buy commercial scripts like VASST Ultimate S Pro or JetDV’s Excalibur that can do this and a whole lot more. There are trials that you can download and use on a project to see how you like it. I wrote Ultimate S Pro so I can answer any questions you may have about it.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

  • Bill Clotz

    April 9, 2011 at 4:02 pm

    Alright, thanks for the help everyone!

  • Dave Gillespie

    October 28, 2012 at 1:59 am

    I’m trying to insert a blank media even between 100’s of short clips. I thought this was just what I needed, but I get errors running this script in Vegas 10 (64 bit)??? I have also tried another one everyone posts, called “2 second gap” that does add gaps, but also extends the media, and sometimes does not add any gap at all. Sees very random. I have tried Excalibur, and it works, but the demo expired and it has tons of things I don’t need, and it to much $$$ for one little script. Any help on why this script does not work in vegas 10?

    Here are the errors-
    C:Program FilesSonyVegas Pro 10.0Script Menuadd gap.cs(29) : A namespace does not directly contain members such as fields or methods
    C:Program FilesSonyVegas Pro 10.0Script Menuadd gap.cs(32) : Expected class, delegate, enum, interface, or struct
    C:Program FilesSonyVegas Pro 10.0Script Menuadd gap.cs(33) : Expected class, delegate, enum, interface, or struct
    C:Program FilesSonyVegas Pro 10.0Script Menuadd gap.cs(38) : Expected class, delegate, enum, interface, or struct
    C:Program FilesSonyVegas Pro 10.0Script Menuadd gap.cs(48) : Expected class, delegate, enum, interface, or struct
    C:Program FilesSonyVegas Pro 10.0Script Menuadd gap.cs(49) : Type or namespace definition, or end-of-file expected

  • Mithun Kumar

    January 1, 2015 at 7:12 pm

    Thanks for this script. Saved my day !!!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy