Stream Length in Script

RichMcG wrote on 1/18/2004, 8:15 PM
I am trying to create a script that loads a series of videos. When I load a video I user the following line:

var media = new Media(Base_filename + j + ".MPG");
var stream = media.Streams[0];


Should the stream be set with the video I just loaded and should the length be set appropriately?

Below is a copy of part of the script I am putting together. I've broken videos into smaller chunks and am putting them back together here. I need to load a simple mpg video into a vegas project and load the audio and video separately with no effects. I was unable to find a script that did this exactly and the below is take from a little javascript knowledge and looking at the scripts available at sites on the web. Any ideas?


Rich


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



Vegas.Cursor = cursorTimecode;
var media = new Media(Base_filename + j + ".MPG");
MessageBox.Show(Base_filename + j + ".MPG");
var stream = media.Streams[0];
MessageBox.Show("Length" + stream.length);
var newEvent = new VideoEvent(cursorTimecode, stream.length);
MessageBox.Show("After New Event");
Vidtrack.Events.Add(newEvent);
MessageBox.Show("After Add VidTrack");
var take = new Take(stream);
MessageBox.Show("After New take");
newEvent.Takes.Add(take);
MessageBox.Show("After New Event");
newEvent.Length = stream.Length;
MessageBox.Show("After Length");
cursorTimecode = stream.Length + Vegas.Cursor;

Comments

jetdv wrote on 1/19/2004, 6:37 AM
In this segment of code you are correctly using stream.length:

var newEvent = new VideoEvent(cursorTimecode, stream.length);

However, here you have changed it to stream.Length:

newEvent.Length = stream.Length;

Try changing the capital "L" to a lower case "l".

Also, if you know that is the LAST thing on the track, you could use:

cursorTimecode = Vidtrack.Length;