looking for "last frames cutter" script

Alex-FICK wrote on 3/2/2009, 7:58 AM
Hi,
THIS IS MY PROBLEM:
I own a Sony AVCHD camera HDR-SR1. When I import AVCHD (M2TS) files into my PC, I import those file into Vegas 8.0, then select them and put in the timeline, I have the following problem.
In about 90% of the imported clip, the last frame (so the last one you find in the far right end in the timeline) is not really the last recorded frame but one of the following:
1) it is the same as the FIRST frame of that clip (so a kind of "loop" effect") OR
2) it is the same as the last but one or the third from last (so the action stops or goes back) OR
3) (rarely) the frame belongs to the following or the previous clip.

So I am looking fot a SCRIPT that automatically cuts the last (or better the last 2 or 3 frames in each clip that I put in the timeline.
This would be the only solution, otherwise I waste a lot of time to cut those frames manually clip by clip! Many many thanks if you can help!

Maybe this issue has been already (partially) discussed in another topic (http://www.sonycreativesoftware.com/forums/ShowMessage.asp?MessageID=634834&Replies=4).

Comments

jetdv wrote on 3/2/2009, 8:14 AM
Here's an old one I wrote for Vegas 5 called "TrimFrontAndBack.js". Right now it changes both the front an back the same amount. You could change it so the front does not get adjusted and change the "TrimAmt" to be the number of frames you want trimmed (it's set to 1 second right now).


/**
* This script will trim the front and back for all selected events.
*
* Written By: Edward Troxel
* Copyright 2004 - JETDV Scripts
* Modified: 08-03-2005
**/

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


var trimAmt = new Timecode("00:00:01:00");


try {

//Go through the list of Tracks
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());

//Go through the list of Events
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());

if (evnt.Selected) {
var dStart = evnt.Start + trimAmt;
var dLength = evnt.Length;

//Get current take offset
var tke = evnt.ActiveTake;
var tkeoffset = tke.Offset;
tkeoffset = tkeoffset + trimAmt;
evnt.Start = dStart;
tke.Offset = tkeoffset;

dLength = dLength - trimAmt - trimAmt;
evnt.Length = new Timecode(dLength);
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}


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


To not trim the front also, remove this section:


//Get current take offset
var tke = evnt.ActiveTake;
var tkeoffset = tke.Offset;
tkeoffset = tkeoffset + trimAmt;
evnt.Start = dStart;
tke.Offset = tkeoffset;


and change this line:
dLength = dLength - trimAmt - trimAmt;

to this:
dLength = dLength - trimAmt;
Alex-FICK wrote on 3/4/2009, 7:22 AM
Many thanks, Edward, for your help. Now, since I am a beginner in this field (I have never created a script before), I'll try to find online some tutorials about "the ABC of the scripts"!
jetdv wrote on 3/4/2009, 7:38 AM
Copy the text, paste it into notepad, and save it as something like "LastFramesCutter.js" in the {My Documents}/Vegas Script Menu folder (you'll probably have to create it). Then it will automatically appear in the list of available scripts under Tools - Scripting.
Alex-FICK wrote on 3/4/2009, 9:14 AM
It works perfectly, many many thanks!
ToranDell wrote on 7/25/2009, 1:52 PM
I have a similar issue to the original poster. I have tried running the script jetdv posted (both the with the suggested modification and the original) but there seems to be no effect on the events when I run the script.

I am running Pro v8.0c. Am I missing something?

Thanks for any help.
ToranDell wrote on 7/26/2009, 2:49 AM
Sorted the problem.