I need help with a part of my script that adds a region on the timeline that will be used for a batch render. My first region (group of videos next to each other) is correct on the timeline. However, for the rest of the group of videos on my timeline only the INITIAL region marker is correct for those groups of videos, but the end markers for them are way off. I used a MessageBox to print out the end marker (Timecode cursorPosition in my code) before using the Region constructor and the MessageBox outputs the CORRECT timecode, but on the timeline it doesn't match up. I believe the issue is near the Region constructor if the code is too long.
To make it short here is what my code is producing:
And here is what I want (ones with checks):
My code:
try { Timecode cursorPosition = new Timecode();// new Timecode() I could just change this to 000000 usign the constuctor //cursorPosition++; //string imagePath = "E:\\Videos\\Highlights\\Highlights0\\Bridget.PNG"; //VideoEvent imageEvent = (VideoEvent)AddMedia(myVegas.Project, imagePath, 0, cursorPosition, Timecode.FromSeconds(10)); int counter = 0; int dumbcounter = 0; string basicPath = @"E:\Videos\Highlights\Highlights"; string intro = @"E:\Videos\Highlights\Intro\HidekiLow.mp4"; string outro = @"E:\Videos\Highlights\Outro\HidekiLow.mp4"; while (counter < 5) { string currentFolder = basicPath + counter; string[] fileNames = Directory.GetFiles(currentFolder, "*.mp4").Select(Path.GetFileName).ToArray(); Timecode initialStart = new Timecode(); Timecode endPosition = new Timecode(); foreach (string fileName in fileNames) //Need to only get files of mp4 because vegas will autocreate those terrible files. NOTE FOR THIS TO WORK A VIDEO TRACK AND AUDIO TRACK SHOULD ALREADY BE MADE { if (dumbcounter == 0) { initialStart = cursorPosition; //MessageBox.Show("The value of intro is " + intro); //MessageBox.Show("The value of cursorPosition is " + cursorPosition.ToString()); Media mediaIntro = Media.CreateInstance(myVegas.Project, intro); Timecode lengthIntro = mediaIntro.Length; VideoEvent v1EventIntro = (VideoEvent)AddMedia(myVegas.Project, intro, 0, cursorPosition, lengthIntro); //The number after specificFile is the track index aka how many rows should the video have. Cursor position is point on the timeline. AudioEvent v2EventIntro = (AudioEvent)AddMedia(myVegas.Project, intro, 1, cursorPosition, lengthIntro); cursorPosition = cursorPosition + lengthIntro; dumbcounter++; } string specificFile = currentFolder + @"\" + fileName; //MessageBox.Show("The value of specificFile is " + specificFile); //MessageBox.Show("The value of cursorPosition is " + cursorPosition.ToString()); Media media = Media.CreateInstance(myVegas.Project, specificFile); Timecode length = media.Length; VideoEvent v1Event = (VideoEvent)AddMedia(myVegas.Project, specificFile, 0, cursorPosition, length); //The number after specificFile is the track index aka how many rows should the video have. Cursor position is point on the timeline. AudioEvent v2Event = (AudioEvent)AddMedia(myVegas.Project, specificFile, 1, cursorPosition, length); //Adds audio but video has no audio file. Should work cursorPosition = cursorPosition + length; endPosition = cursorPosition; } MessageBox.Show("The value of initialStart is " + initialStart.ToString()); MessageBox.Show("The value of cursorPosition is " + cursorPosition.ToString()); endPosition = cursorPosition; MessageBox.Show("I am ADDING A REGION THAT IS FROM " + initialStart + " to " + cursorPosition); ScriptPortal.Vegas.Region region1 = new ScriptPortal.Vegas.Region(initialStart, cursorPosition); myVegas.Project.Regions.Add(region1); cursorPosition = cursorPosition + Timecode.FromSeconds(120); counter++; dumbcounter = 0; } }