Cuts-only editing scripts

johnmeyer wrote on 9/23/2004, 10:11 PM
These two scripts are designed to let you complete a "cuts-only" editing project as quickly as possible. I usually do my rough cuts with these script by putting the video on tack one, and the audio below, and then start the edits, with no other tracks. However, the scripts work just fine if you have lots of tracks. Just make sure you select the video track you want to work on, and make sure the audio for that track is on the track directly below. Also, if you have a multi-track project, these scripts will not ripple the other tracks.

So, here goes.

If you want to become a cuts-only editing speed demon, you need to:

1. Develop a rhythm.
2. Minimize your movements (keyboard and/or mouse).
3. Eliminate thinking.

Everyone develops a different editing style, so what I've developed here may or may not work for you. However, give it a try and see. Here is how I use these two scripts.

1. Put the scripts in the directory where you have your other scripts.
2. Use the Keyboard tab in the Options menu to assign keyboard shortcuts to these two scripts. I use Ctrl-1 for the script that deletes from the cursor to the beginning of the event, and Ctrl-2 for the script that deletes the event under the cursor.
3. Put your video on the timeline, and start at the beginning of the timeline.
4. Scrub through the video using the J-K-L keys. You can set the scrub speed range in the Edit tab of Options menu. I use the default (Medium). When you get to a point where you want to edit, you have three decisions to make:

a. You don't like anything you've seen in this event up to the current location, but you just reached the good stuff and want to keep everything from this point until some point later. In this case simply press Ctrl-1 (delete from cursor to beginning of event) and everything from the current cursor location to the beginning of the event is deleted; and the cursor is positioned at the beginning of the event (which is the same frame of video at which you were already located). All later events are rippled (it doesn’t matter if ripple edit is turned on or not — I usually keep it turned off when using these scripts). The event immediately following the new cursor location is selected, mostly to visually help you locate where you are.

b. The second scenario is where you like EVERYTHING up to this point, but now have come to a section you don't like. In this case, press the S key to split the event, and keep on scrubbing into the newly-created event. The S key automatically highlights the event I am moving into and de-selects the left side of the split. This is consistent with what happens in (a).

c. The final scenario is where you don't like anything in this event. I press Ctrl-2 and it deletes the event under the cursor, ripples all the subsequent events, moves the cursor to the beginning of what, prior to deleting the event, was the next event, and highlights that event to show you where you are.

Thus, to delete to the left of the cursor, you press the left-most key combination (Ctrl-1), and to delete under the cursor or to the right, you press the right-most key combination (Ctrl-2). To split the event, you simply press S. The whole left-right thing is also consistent with the J-K-L shuttle combination. I suppose to be totally consistent, you could assign the split function to Ctrl-2 and then assign the delete event under the cursor to Ctrl-3.

With these scripts you don't have to worry about what event is selected or not selected. All that matters is the cursor location and the track selection. This eliminates all sorts of errors that can happen if you accidentally have more than one event selected and press the delete key. Also, since the ripple is handled by the scripts, you don't get the surprises that Vegas' own ripple editing sometimes provides.

Here's the script that cuts from the current cursor location to the beginning of the event. I posted an earlier version of this a year ago, but this has been refined somewhat, and works with 5.0b.

/** 
* PURPOSE OF THIS SCRIPT:
*
* Delete frames from cursor to start of event, and then move all events to the left by n frames.
*
*
* A video track must be selected. If an audio track is selected, nothing happens.
* The video event on the track that lies beneath the cursor
* will be shortened from the cursor to the start of the event.
* If the track beneath the video track contains audio, the audio event in that track
* that lies beneath the cursor will also be shortened by the same number of frames.
*
* Copyright © John Meyer 2004
* Written: June 4, 2003
* Updated: September 23, 2004
*
**/

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

try {

//Global declarations
var dStart : Double;
var dLength : Double;
var dCursor : Double;
var trackEnum : Enumerator;
var evnt : TrackEvent;

var EventBegin : Timecode = Vegas.Cursor; // Use this to move cursor position.
var track = FindSelectedTrack(); // Use this function to find the first selected track.
var eventEnum = new Enumerator(track.Events);
var BeyondCursor : boolean = false; // This flag used to notify if event is to right of cursor.

if (track.IsVideo()) { // Proceed only if selected track is video track.

if ( TrimEventAtCursor() ) { // Function that trims event and moves all remaining events on track left.

// Get set to look at track directly below the video track.
BeyondCursor = false;
trackEnum.moveNext(); // Go to next track.


if (!trackEnum.atEnd()) { // Only proceed if there is a track below the video track.
track = Track(trackEnum.item()); // When doing the first track (above), these two lines were executed
eventEnum = new Enumerator(track.Events); // in the FindSelectedTrack() function.
if (track.IsAudio()) { // Only trim the event if this is an audio track.
TrimEventAtCursor();
}
}
}
}
Vegas.UpdateUI();

// Move cursor to start of selected event (cursor stays at same media location).
Vegas.Cursor = EventBegin; // Remove this line to keep cursor in same location.

} catch (e) {
MessageBox.Show(e);
}

// End of main program



// Beginning of functions

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 finds the event on the selected track
* that lies under the cursor. It also deselects all other events.
*
**/

function TrimEventAtCursor() {

var EventFound : boolean = false; // Function returns false if no video media under cursor.
var DeleteFrames : Timecode = new Timecode("00:00:00:00");
var DeleteTime : Double = DeleteFrames.ToMilliseconds();

dCursor = Vegas.Cursor.ToMilliseconds(); // Remember the cursor position.

//Go through each event on the track.

while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event


// Get the event's start and length timecode, in milliseconds.
dStart = evnt.Start.ToMilliseconds();
dLength = evnt.Length.ToMilliseconds();


if (BeyondCursor) { // Move, but don't truncate events to the right of the event under the cursor.
// evnt.Start=evnt.Start-DeleteFrames; // Use this line for versions of Vegas prior to 4.0d
evnt.AdjustStartLength(evnt.Start-DeleteFrames, evnt.Length, true); // Use this line with 4.0d and beyond.
}

/**
* If the cursor timecode is between the beginning and end of the
* event timecodes, then select the event, and trim start by n frames.
* Move selected event and all events to right of cursor to left by n frames.
**/

if ( (dCursor >= dStart) && ( dCursor < (dLength + dStart) ) ) {
evnt.Selected = true; // Select this event.
EventFound = true;
BeyondCursor = true; // Remaining events are to right of cursor.
DeleteFrames = Vegas.Cursor - Timecode(evnt.Start);
DeleteTime = DeleteFrames.ToMilliseconds();
EventBegin = evnt.Start;
dLength = dLength - DeleteTime;

// Next two lines truncate start of event, and then move it left
// by the same amount that it was truncated.
evnt.AdjustStartLength(new Timecode(dStart), new Timecode(dLength), false);
evnt.ActiveTake.Offset = DeleteFrames+evnt.ActiveTake.Offset;
}

eventEnum.moveNext(); // Go to next event on this timeline.

}
return EventFound;
}


Here's the script that deletes the event under the cursor:

/** 
* PURPOSE OF THIS SCRIPT:
*
* Delete the event under the cursor, including the associated audio.
* Ripple remaining events on the video and associated audio tracks (but not on other tracks).
* Select the event that "ripples into" the space left by the deleted event,
* and then put the cursor at the beginning of this event.
*
* A video track must be selected. If an audio track is selected, nothing happens, and you get an error message.
* If the track beneath the video track contains audio, the audio event in that track
* that lies beneath the cursor will also be deleted, and subsequent events rippled.
*
* Since the audio for a video event is sometimes shorter, the length of the video event is used
* to ripple the audio event, to make sure everything lines up the same way as it did prior to the ripple.
*
* Also, Vegas has all sorts of crazy internal roundoff errors which cause problems when the cursor
* is on the event boundary, so a "slop" variable is used to "forgive" slight errors. If you set this
* variable to zero, you will get strange behavior -- but only sometimes -- when the cursor is at the event
* boundaries.
*
* (One side note: This roundoff can cause problems when using Vegas without scripts -- beware.)
*
* Copyright © John Meyer 2004
* Written: September 23, 2004
* Tested on Vegas 5.0b
*
**/

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


try {

//Global declarations
var dStart : Double; // Start of event
var dLength : Double; // Length of event
var dCursor : Double; // Current cursor position
var NewCursorPos : Timecode; // Used to position cursor at start of next event, after deletion
var RippleLength = new Timecode("00:00:00:00");
var dSlop : Double = 0.1; // Variable needed because Vegas is sloppy and doesn't
// make audio and video exactly the same length
var trackEnum : Enumerator;
var evnt : TrackEvent;

var track = FindSelectedTrack(); // Function to find the first selected track.
var eventEnum = new Enumerator(track.Events); // List of events on this track

if (track.IsVideo()) { // Proceed only if selected track is video track.

if ( SelectEventAtCursor() ) { // Function that selects and removes event under cursor.
trackEnum.moveNext(); // If success on video track, go to next track.
if (!trackEnum.atEnd()) { // Only proceed if there is a track below the video track.
track = Track(trackEnum.item());
if (track.IsAudio()) { // Only trim the event if this is an audio track.
eventEnum = new Enumerator(track.Events);
SelectEventAtCursor();
} // End If track.IsAudio()
} // End If !trackEnum.atEnd()
} // End If SelectEventAtCursor()

Vegas.Cursor = NewCursorPos ; // Before finishing, put cursor at beginning of event
} // immediately after deleted event.

else {
MessageBox.Show ("You need to select the video track, not the audio track", "Alert");
} // End track.IsVideo()

Vegas.UpdateUI(); // Update the UI.

} // End try

catch (e) {
MessageBox.Show(e);
}

// End of main program


// Beginning of functions

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 finds, selects, then deletes the event on the selected track
* that lies under the cursor. It also deselects all other events on the selected track.
*
**/

function SelectEventAtCursor( ) {

var EventFound : boolean = false; // Function returns false if no video media under cursor.
dCursor = Vegas.Cursor.ToMilliseconds(); // Remember the cursor position.

while (!eventEnum.atEnd()) { // Go through each event on the track.
evnt = TrackEvent(eventEnum.item()); // Get next event
evnt.Selected = false; // De-select the event
dStart = evnt.Start.ToMilliseconds(); // Get the event's start and
dLength = evnt.Length.ToMilliseconds(); // length timecode, in milliseconds.

// If the cursor timecode is between the beginning and end of the
// event timecodes, then select and delete the event.

if ( (dCursor >= dStart) && ( dCursor < (dStart + dLength - dSlop) ) ) {

evnt.Selected = true; // Select this event.
EventFound = true; // Notify calling function that event was found
if (RippleLength.ToMilliseconds()<1) { // If ripple length was previously set to video length,
RippleLength = evnt.Length; // (i.e., it is non-zero) don't reset. Use video length
} // to ripple audio (because audio may not be same length as video)
NewCursorPos = evnt.Start; // At end of script, move cursor to where this event used to start
track.Events.Remove(evnt); // Remove the event
eventEnum = new Enumerator(track.Events); // Removing the event screws up enumeration, so start over
evnt = TrackEvent(eventEnum.item());
dStart = evnt.Start.ToMilliseconds(); // Recompute the event's start and
dLength = evnt.Length.ToMilliseconds(); // Recompute length timecode, in milliseconds.
} // End If dCursor (etc.)

if ( (dCursor < dStart) ) { // If cursor is to left of this event, then ripple.
evnt.AdjustStartLength(evnt.Start - RippleLength, evnt.Length, true);
dStart = evnt.Start.ToMilliseconds(); // Event has moved, so recompute the event's start and
dLength = evnt.Length.ToMilliseconds(); // length timecode, in milliseconds.

if ( (dCursor >= dStart) && ( dCursor < (dLength + dStart) ) ) {
evnt.Selected = true; // Select the event that "replaced" the removed event
}
} // End if ( (dCursor < dStart) )

eventEnum.moveNext(); // Go to next event on this timeline.
}
return EventFound;
}

Comments

BrianStanding wrote on 9/27/2004, 7:32 AM
Awesome! Great timesaver! I use all your scripts -- it's obvious you do a lot of hands-on editing. You da bomb!
johnmeyer wrote on 9/27/2004, 3:15 PM
You da bomb!

I think that's a good thing ;)

Thanks!
fuzi wrote on 11/4/2004, 9:59 AM
John,
It is very nice ! The only problem is that after deleting to the start of the events, the markers remain where they were, instead of changing their absolute position.
I think it would be an easy job for you to make an other variation of this useful script !

Thanks
Csaba
johnmeyer wrote on 11/5/2004, 8:12 AM
Csaba,

I have a newer version of these scripts over at Sundance that I uploaded last week. They don't have marker or region ripple edit, but they do fix some bugs.

I don't program every day, so whenever I go back to it, I have to look up almost every command, so it is a slow process. I know exactly what it would take to add marker and region ripple editing and it would be pretty straightforward. However, it would take me 2-3 hours, almost all of it trying to find the code to enumerate the region list and marker list, and then adding the marker/region reassignment code to the ripple section of the script.

Thus, it is not a difficult task, and it is a good, reasonable request. However, because I have to climb this learning curve each time I do programming (in any language, not just jscript) I just don't have the time to do this now. Sorry.
MichaelS wrote on 11/5/2004, 8:19 PM
Outstanding!
johnmeyer wrote on 11/5/2004, 11:33 PM
Thanks Michael. I wish more people would try them, especially those at Sony. With all due respects to all the wonderful design decisions in Vegas, the interaction between cursor, event selection, track selection, and timeline selection is still not optimal. You can't fully appreciate this until you use these scripts and suddenly realize that all you have to worry about is the position of the cursor. You do have to select a track (which you can do by just selecting one of the events on the track), and then after that, you just let the cursor be your guide. I just got finished with a rough cut of a five hundred event sports video (which will eventually be cut down to about one hundred events). It was a completely painless operation.

I'm not tooting my own horn, because the scripts are really pretty pathetic. Rather, I am simply pointing out that there really is a MUCH better way to do things, at least for simple cuts.
Erk wrote on 11/14/2004, 9:10 PM
johnmeyer,

Really outstanding, very useful work you've done here! I had just gotten to used to 1/2 your style described above, having the "delete til cursor" script, but not its opposite. With a shuttle control of some sort, it makes for very fast cutting indeed.

Greg
johnmeyer wrote on 11/14/2004, 11:50 PM
Greg,

I assume you downloaded the latest version of the script from Sundance. If not, here is the link (they were updated about two weeks ago).

Cuts-Only Scripts
BrianStanding wrote on 11/16/2004, 12:51 PM
john,

When using these scripts, I've noticed something that (I think) only occurs if I happen to have Auto Ripple turned on.

After I use either of these scripts, it seems events further down the timeline are slip edited (length remains same, but in and out points are moved leftward) by an amount that corresponds to the length of the clip I just cut using your script. Needless to say, this is a bear to fix. I haven't had time to really test this out , though, so I may just be whistling in the dark.

I know Auto Ripple is a bad idea in any event, but there are circumstances where it's pretty handy. I know you said you use a different method to close gaps in your script, so maybe there's something weird about the interaction between your method and Vegas' Ripple edit.

Can you confirm this rather odd behavior?
johnmeyer wrote on 11/16/2004, 2:57 PM
After I use either of these scripts, it seems events further down the timeline are slip edited (length remains same, but in and out points are moved leftward) by an amount that corresponds to the length of the clip I just cut using your script.

I tested all the scripts both with and without various ripple edit modes, and there is no difference. Scripts are independent of the ripple edit mode, so I would be surprised if this would make a difference.

However, there was a change made to Vegas in version 4.0d that affected the script command that is used to adjust the position and length of the event.

If you do not have Vegas version 4.0d or later, the script will not work correctly.

My initial post above, and the post at the Sundance site all state that the script was only tested on 5.0b. I am pretty certain it works OK with this version (as I stated above) and would be pretty confident that it will work with 4.0d, 4.0e, 5.0, and 5.0a. It definitely will not work with versions earlier than 4.0d.
BrianStanding wrote on 11/17/2004, 8:56 AM
I'm using 5.0b. I'll do some more testing and see what's really going on.
Erk wrote on 12/31/2004, 8:17 PM
johnmeyer,

I'm using Vegas 5.0b, and the "delete from cursor" script is doing something strange with the loop points of events further down the same track. They appear to be off by the amount trimmed from the event edited by the script. This happens with auto-ripple on or off.

I think earlier versions of this script were working OK on my Vegas, but I can't be sure.

Greg
cadudesun wrote on 7/10/2017, 8:41 AM

Hi.

The "Cuts-only editing scripts" sound very very handy.

Is it possible anyone share an updated version which works with VEGAS PRO 14?

Many thanks in advance!

Carlos_Cadu

Marco. wrote on 7/10/2017, 10:43 AM

You don't need these scripts anymore as these are core functions in Vegas Pro since quite a few years now (this thread was started 13 years ago!).

johnmeyer wrote on 7/10/2017, 1:34 PM

Actually, these scripts do something quite different than anything Vegas has ever provided. I've used Vegas since version 4 and, unfortunately, the "core functions" have not been upgraded much since then. As a result, these scripts are still quite valid, useful and, in my experience, will let you get through a "cuts-only" editing session, using a single timeline, in about 1/5 the time it would take using Vegas' native editing.

I haven't posted here in three years because of Sony's neglect of the software and, more recently, because this forum software is so awful (why the heck didn't Magix just purchase forum software, like every other company??). I am only posting now because I got a PM asking for the scripts. Here is a link to the latest versions which, unlike those I posted years ago, will now ripple markers as well as events.

Cuts-Only Scripts

As I described in my various earlier posts, which you probably can't find because of this forum's incompetent search capabilities (grumble, grumble), these scripts are designed for the simplest situation of doing cuts-only edits on a single track of video and its associated audio. All operations are based on the current location of the cursor and do not depend on which event is selected or not selected. All deletions and trims are also based on the cursor location, thus eliminating one problem with the Vegas UI which, under many scenarios, will give you the surprise of finding that you deleted an event that was selected from a previous operation, but no longer in the current timeline view. That can't happen with these scripts.

These three scripts are useless if you have a multi-track editing project.

--------------

(Wow, I wanted to preview this post, to make sure the link works and that the formatting is the way I want, and realized that there is no preview feature. I've been doing online forums since dial-up BBS and, later, Compuserve and AOL. This forum software is a joke!! What button do I click on to post?? OMG, I click on "Comment?" Really? The word "comment" is a noun as well as a verb, so it is an ambiguous and incompetent choice. Is there a problem of using the word "submit," like most other forums? Also, neither "comment" nor "cancel" are formatted as buttons and therefore the user has to rely on the text color to know that it is something that should be clicked. Obviously, once you know, you can get it to work, but why throw out twenty years of UI convention?)

After I quit posting three years ago, I still read the forum almost every day, but after Magix took over and installed this incompetent forum software I quite doing that because the formatting, flow, and topic selection is so goofy and stupid that I can't quickly scan and determine what to read.

What is really sad (for me) is that I can no longer find anything that I wrote in my 7,000 posts, nor can I easily find posts from the great gurus from the past who wrote wonderful things that I often want to find in order to remember some insight or trick.

Oh well, I've moved on and have figured out how to make older versions of Vegas work great with modern video, so I can still get lots of work done.

vkmast wrote on 7/10/2017, 1:57 PM
What is really sad (for me) is that I can no longer find anything that I wrote in my 7,000 posts, nor can I easily find posts from the great gurus from the past who wrote wonderful things that I often want to find in order to remember some insight or trick.

While I agree with much of what you say about the forum and "Search", you can in fact still find your (and others') contributions.

The archived SCS forums are here http://forum-archive.magix.info/home. Some of the Search options are still useful there.

 

Marco. wrote on 7/10/2017, 2:40 PM

John, these core trim functions were not available in VP4, them came in version 12 (or 11).

"Trim Start" trims from the cursor position to the beginning of the Event.

"Trim End" trims from the cursor position to the end of the Event.

If no Event is selected, all events under the cursor will be trimmed. If a certain Event is selected, only this certain Event will be trimmed. Trimming is aware of grouping and rippling.

I think the difference between the script and the core function is, when there is one Event selected but you want to trim a different Event this won't work with the core function - it needs either to have that certain one or none at all selected.
While this is an advantage of the script solution, the core function may be preferable if you solely want to trim one Event but not the Events which are on same time position on another tracks.

So there may be some use for both the trim solutions. Also there is another extension available at SeMW-software.com. Its "Split and Heal" functions work in the way to be track sensitive. It doesn't matter which Event is selected but it cares for which tracks are selected to split and trim (and join) Events.

Many choices.

cadudesun wrote on 7/11/2017, 4:51 PM

Hi John,

Many thanks for you kind attention and sharing of your plugins!

After testing then, I realized that although current Vegas inbuilt "trim start/ends" has similar functionality than plugin "delete from cursor to event start" (the later works at selected track, Vegas cuts all tracks), you made available two other plugins in the pack:

- Delete event under cursor

- Select video and audio at cursor

These are worth functionalities I couldn't find how to perform in current Vegas 14 using just the keyboard.

I attach shortcuts to these scripts and now, when editing, I can achieve a handy workflow, complementing Vegas inbuilt functionality in a way that I don't need to touch the mouse. All my primary cuts and editing are fully keyboard oriented now.

By the way, I performed a small change in your original scripts in order they can work with VP14 (replacing Sony.Vegas to ScriptPortal.Vegas). The modified three scripts are available through the link https://goo.gl/SfmTvX

Cheers!

Carlos_Cadu