Comments

Quitter wrote on 11/18/2016, 11:44 PM

/**
* Program:
* Description: This script deletes empty space between events,
* and removes all overlaps between events, and removes all event fades
* on all tracks.
* No attempt is made to synchronize audio and video events.
* Author: John Meyer
* April 9, 2007
*
**/

import ScriptPortal.Vegas;
import System.Windows.Forms;

try
{

  // step through all selected video events:
  for (var track in Vegas.Project.Tracks) {

    var tracktime = track.Events.Item(0).Start;
    var Fadelength : Timecode = new Timecode("00:00:00.00");

    for (var evnt in track.Events) {

        var currTake : Take = evnt.ActiveTake;
        var currOffset : Timecode = evnt.ActiveTake.Offset;
        evnt.Start = tracktime;
        currTake.Offset = currOffset;

    evnt.FadeIn.Length = new Timecode(Fadelength);
    evnt.FadeOut.Length = new Timecode(Fadelength);

        tracktime = tracktime + evnt.Length;

    }
  }

}

catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

Camcorder: Sony CX 520 VE
Hardware:   Acer NG-A717-72G-71YD, Win 11 , i7-8750 H, 16GB, GTX 1060 6GB, 250GB SSD, 1TB HDD
NLE:  Sony Vegas Pro 13.0 Build 453
            Vegas Pro 14.0 Build 270
            Vegas Pro 21.0 Build 300

 

arkadiusz-buchala wrote on 11/19/2016, 1:17 AM

Thank you Quitter!😄

It is not this one that caused problems with the clips?

Quitter wrote on 11/19/2016, 1:37 AM

I got no probs

Camcorder: Sony CX 520 VE
Hardware:   Acer NG-A717-72G-71YD, Win 11 , i7-8750 H, 16GB, GTX 1060 6GB, 250GB SSD, 1TB HDD
NLE:  Sony Vegas Pro 13.0 Build 453
            Vegas Pro 14.0 Build 270
            Vegas Pro 21.0 Build 300

 

arkadiusz-buchala wrote on 11/19/2016, 2:00 AM

It did not mess up start and end of the clips?

arkadiusz-buchala wrote on 11/19/2016, 2:02 AM

I have a script that did a good work in Vegas 13, but it's not working in Vegas 14:

/** 
* Program: 
* Description: Remove gaps between events. This removes gaps in SELECTED events only. The remove gap function only works on selected events. 
               All events before and after the selected event are NOT processed. The GAP constant is used as the defined spacer between events
               as they are processed. If you want the space between events to be 0, then set GAP to 0. GAP unit is milliseconds. Default is 1000 (1sec).
               This script was created because the only other RemoveGaps script found on the interet had a bug where it truncated the end of each event
               on complex tracks. This script works on complex tracks with 1000's of events. Also the other script processed all events on a track, this
               script processes only selected tracks, so you can selectivly decide which evemts to process and which to not process.
* Author: JRD

* Date: April 17, 2011
**/ 

import Sony.Vegas; 
import System.Windows.Forms;
import Microsoft.Win32;
import System.Diagnostics;


try
{
    Debug.WriteLine("RemoveGaps-> START");
    
    var GAP = 1000;

    // step through all selected video events:
    var FirstTrack : Track = Vegas.Project.Tracks.Item(0);
    var idx = 0;
    var countSel = 0;
    // step through all selected video events:
    for (var track in Vegas.Project.Tracks) 
    {
        if( !track.Selected || track.MediaType == MediaType.Audio) continue;
        
        var tracktime = new Timecode(0);
        var last = 0;
        var begin = 0;
        for (var evnt in track.Events) 
        {
            if (evnt.Selected)
            {
                // start after first event
                if (idx > 0 && countSel > 0)
                {
                    Debug.WriteLine("RemoveGaps-> idx -> " + idx);
                    // get diff between previous this event and last
                    var diff = (evnt.Start.ToMilliseconds() - last); 
                    Debug.WriteLine("RemoveGaps-> diff -> " + diff);
                    //  if diff is greater than GAP? then fill it
                    if (diff > GAP)
                    {
                        var start = Timecode.FromMilliseconds(last + GAP);
                        var end =  Timecode.FromMilliseconds(start.ToMilliseconds() + evnt.Length.ToMilliseconds());
                        var len =  Timecode.FromMilliseconds( evnt.End.ToMilliseconds() - evnt.Start.ToMilliseconds());
                        
                        Debug.WriteLine("RemoveGaps-> diff > GAP " );
                        Debug.WriteLine("RemoveGaps-> diff > Set evnt.Start to-> " + start.ToMilliseconds().ToString());
                        Debug.WriteLine("RemoveGaps-> diff > Set evnt.End to-> " + end.ToMilliseconds().ToString());
                        Debug.WriteLine("RemoveGaps-> diff > Set evnt.Length to-> " +len.ToMilliseconds().ToString());
                        
                        evnt.Start = start; // new start
                        evnt.End = end; // new end
                        evnt.Length = len; // calculate exact length
                        countSel++;
                    }
                }
                countSel++;
            }
            last = evnt.End.ToMilliseconds();
            tracktime = tracktime + evnt.Length;
            idx++;
        }
    }
    Debug.WriteLine("RemoveGaps-> DONE");
}

catch (errorMsg)
{
    Debug.WriteLine("RemoveGaps-> ERROR-> " + errorMsg);
    MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

NickHope wrote on 11/19/2016, 2:49 AM

Change

import Sony.Vegas;

to

import ScriptPortal.Vegas;

That goes for any script that needs adapting to VP14.

arkadiusz-buchala wrote on 11/19/2016, 3:28 AM

Thank you Nick! This is really helpful 😃!

Quitter wrote on 11/19/2016, 3:46 AM

It did not mess up start and end of the clips?

I know what you are meaning (have used that wrong script too)
But this one doesn't, it works fine (and it moves the related audio too)
 

Last changed by Quitter on 11/19/2016, 3:55 AM, changed a total of 2 times.

Camcorder: Sony CX 520 VE
Hardware:   Acer NG-A717-72G-71YD, Win 11 , i7-8750 H, 16GB, GTX 1060 6GB, 250GB SSD, 1TB HDD
NLE:  Sony Vegas Pro 13.0 Build 453
            Vegas Pro 14.0 Build 270
            Vegas Pro 21.0 Build 300

 

arkadiusz-buchala wrote on 11/19/2016, 7:08 AM

So it's even better :)