Request help trom John Meyer

Yodasen wrote on 10/2/2003, 10:08 AM
I have used your script "deletenextN.js and found it very useful! Thanks for your contribution. My need is for a script that will do exactly what your script does and also delete the last 4 frames in each event. Could you modify your script to this. I am just getting started with Vegas /Scripting/ Burning and there is no way I could do this at my present level. Thanks in advance for any help you could provide.

Note to forum users - this is my first post and I am sure it is in the wrong place. I am a newbe - Please don't Spank me.

Comments

jetdv wrote on 10/2/2003, 11:28 AM
Change:


evnt.AdjustStartLength(new Timecode(dStart), new Timecode(dLength), false);
evnt.ActiveTake.Offset = DeleteFrames+evnt.ActiveTake.Offset;
}


to:


evnt.AdjustStartLength(new Timecode(dStart), new Timecode(dLength), false);
evnt.ActiveTake.Offset = DeleteFrames+evnt.ActiveTake.Offset;
dLength = dLength - DeleteTime;
}


Does that do what you want? (Two new lines of code in bold)
Yodasen wrote on 10/2/2003, 12:40 PM
jetdv

I copied and pasted your change to the file. It does not do what I need.
My problem is every time I stop my sony MicoMV video camera it saves 1 or 2 frames at the end of the event as a still picture for a menu feature in the camera. I need to clip all these "stills ' off. Also my video frames are 2 or 3 frames longer than the audio from the camera. Your edit choped off frames from the end but preserved the video to audio frame stagger that I need to cut off even. Also it appears to only work on the selected event and not all the events following and did not "ripple" the events together as the unedited file did. Maybe I edited the file wrong. I'm very new to this. Thanks

Here is the exact keystrokes it takes to do what I want.

Note: You must have the ripple effect active.

Place the cursor between event #1 and event # 2.

press arrow rightkey (moves one frame into event #2)

hold shift key and press arrow left key 5 times (hightlights 5 frames - 1 at the beginning of event #2 and 4 frames at the end of event #1)

press delete key (5 video frames are deleted and 3 audio frame +2 empty audio frames are deleted and the events are rippled together)

that is the end of the edit I need to do. But I need to do it at every start and stop point on the time line.

It seems simple but is not something most people would need to do. (unless they use a sony dcr-ip5 MicroMV video camera).

It would be nice to have 2 feilds in the script
1. n = number of frames at the beginning of event to trim
2. z = number of frames at the end of the same event to trim.

Again - the staggering of the audio track being 2 -3 frames shorter than the video track might be a problem in a script. It is not a problem using the keystroke above. I know , use a keystroke macro program to do this. I do and it is slow , and the timing issue between when you start the macro and when Vegas is ready can produce different results.

Thanks for any help out there. I'm digging the Vegas thing.
jetdv wrote on 10/2/2003, 2:11 PM
The changes I indicated would not affect WHICH clips were altered in the script. Both Video and Audio would need to be selected before the script was run. That functionality was not changed.

It also will not "ripple" but, then again, it did not do so before. The ripple setting will make no difference. If the program was to ripple, that functionality would have to be added to the program. To close the gaps, I would run Gap Wizard after running this script.

The two lines of code I added simply chop off the last "DeleteTime" number of frames.

And, yes, the keystrokes you mention could be simulated - just not in the way you are talking.
johnmeyer wrote on 10/3/2003, 1:08 AM
Yodasen,

You simply need to delete one line (it's right near the end). I have included the updated script below with this line commented out.

This script is designed to work with 4.0d. If you have an earlier version of Vegas, you need to un-comment one line, and then "comment out" the below (see script for details). If you have 4.0d, then just use as-is.

BTW, I never posted my other script. This one will automatically deletes the video event on the first selected video track, and any audio on the track immediately below, from the position of the cursor to the beginning of the event. Like this script, it doesn't matter which event (or events) are selected. All that matters is that you have a video track selected, and that the cursor is positioned at the point where you wish the trim to occur.

I could post this script, if you have any need or interest.

Here's the script:


/**
* PURPOSE OF THIS SCRIPT:
*
* Delete n frames from end 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 by the number of frames set in the code below (see comments).
* The cursor does not need to be at the beginning of the event; anywhere over the event is OK.
* If the cursor lies at the boundary between events, the event to the right will be truncated.
* 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.
*
* Written By: John Meyer
* With thanks to Edward Troxel
* Written: June 3, 2003
* Revised October 2, 2003
*
**/

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


try {

//Change the next line to set the number of frames to trim.
var DeleteFrames : Timecode = new Timecode("00:00:00:07"); //This is 7 frames.
var DeleteTime : double = DeleteFrames.ToMilliseconds(); // Convert frames to milliseconds.

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

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.
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();

} 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() {

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.
BeyondCursor = true; // Remaining events are to right of cursor.
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);

// This line was deleted to make the program delete at the END of the event.
// evnt.ActiveTake.Offset = DeleteFrames+evnt.ActiveTake.Offset;
}

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

}

return null;
}
johnmeyer wrote on 10/3/2003, 1:14 AM
See my reply in my previous post.