I already have a script which scans a folder full of video clips, loads each clip into the timeline and renders each out using a specified template. Would it be possible to trim each clip before it renders out? Would I be able to specify the time code that I want to render out?
When rendering, you can specify the starting and ending timecodes. How are you rendering from the script now? When making the rendering call you can also specify the beginning and ending timecode.
For my end goal, I think that I will actually need to trim the clip. Is that possible through scripting in Vegas? I have a large amount of footage stored on a network. If I received an "order" from a user containing filenames and timecodes, Would I be able to compile one custom scene from various files, using the time codes given by the user? Maybe even apply transition effects from one trimmed clip to another for the final custom scene.
I would need to:
-Load a file
-Trim using timecodes specified by user
-load second file
-Trim using timecodes specified by user
-"butt" the second file right after the first
-Continue untill custom scene is completed
-Render
I have written scripts for various Adobe products which enables users to generate custom graphics from easy to use web interfaces. I was upset to learn the Premier does not support scripting. If Vegas can do what I would like to do through scripting, my company will definitely be making the switch.
Great. I actually have most of it down. Can you point me to the part of the documentation that deals with trimming the media in the timeline? The method I would be dealing with.
I'm creating a js file. You can't just double click on it to execute the script? Is it really necessary to open the vegas interface and select the script from the menu? Are there any work arounds?
Thanks for the info. I can't seem to get the AdjustStartLength to work. I get a type mismatch error with the following code. I thought it should work, since I'm applying the method to the selected event. Here's the section that's giving me trouble. I get a Type mismatch on the AdjustStartLength line. Any pointers would be greatly appreciated. Thanks.
Thanks, you are very helpful. I thought e.Start(new Timecode(0)); should move the selected event to the beginning of the track. It doesn't seem to do it though. It doesn't give any errors, but the event doesn't move either.
for (var t in Vegas.Project.Tracks) {
for (var e in t.Events){
e.Selected = true;
e.AdjustStartLength(new Timecode(30000), new Timecode(90000), false);
e.Start(new Timecode(0));
}
}
"You may need to adjust the offset as well after moving it."
Would you mind expounding on that?
The code does trim the event as intended, but once I try to move the event to the beginning of the timeline via the e.Start = new Timecode(0);, the event is no longer trimed the same way. Is there a way to just move the event with the trim remaining in tact? Thanks again.
The code could probably be more efficient, but it works. Thanks so much for your help jetdv. I will post my code. It might be helpful to a beginner in the future. I do have one more question. If I wanted to overlap two segments on the timeline and apply a transition to the overlapping region, how would I apply the transition? I'm not asking for the code, if you could just point me in the right direction. Here's my code that will loop through an array of file paths and timecodes, and trim and arrange each clip. I still need to add the code to render at the end.
var Moveto = new Timecode(0);
for(var i=0; i<arrClipInfo.length; i++){
var path = arrClipInfo[i][0];
Vegas.OpenProject(path);
var Count = 0;
for (var t in Vegas.Project.Tracks) {
for (var e in t.Events){
if (e.Index == i){
var thisClipLength = e.Length;
var TrimStart = new Timecode(arrClipInfo[i][1]);
var TrimEnd = new Timecode(arrClipInfo[i][2]);
e.Selected = true;
if (i == 0){
var ClipLength = e.Length;
e.AdjustStartLength(TrimStart, TrimEnd, false);
}else{
e.AdjustStartLength(ClipLength + TrimStart, TrimEnd, false);
}
var currTake = e.ActiveTake;
var currOffset = currTake.Offset;
if (i != 0 && Count == 0){
Moveto = Moveto + TrimEnd;
}
e.Start = new Timecode(Moveto);
currTake.Offset = currOffset;
if (i != 0 && Count != 0){
ClipLength = ClipLength + thisClipLength;
}