I have a series of projects that are nothing but still photos. Most of the photos are overlapped on the timeline, thus producing crossfades. I want to automatically create subtitles for these projects using the file names of each still photo. I use the script below to add regions that are named using the event's file name. I then export these regions using Sony's export to subtitles script.
Problem: A few, seemingly random, events end up with overlapping regions which DVD Architect can't import. In troubleshooting the problem, I found out that that in the line below:
LengthTime = LengthTime - evnt.FadeOut.Length;
that FadeOut.Length is returning zero for the problem events, even though the event is crossfaded with the following event. All the other events that are crossfaded correctly show the FadeOut.Length equal to the duration of the crossfade. (Actually, I have found at least one event that returns a value for the FadeOut.Length that is not zero, but is not the correct value either).
The code below shows the script, including two lines of "troubleshooting" code I was using to stop and look at the fade length for each event.
Does anyone have any ideas as to what is causing this problem? I am using Vegas 5.0d.
Problem: A few, seemingly random, events end up with overlapping regions which DVD Architect can't import. In troubleshooting the problem, I found out that that in the line below:
LengthTime = LengthTime - evnt.FadeOut.Length;
that FadeOut.Length is returning zero for the problem events, even though the event is crossfaded with the following event. All the other events that are crossfaded correctly show the FadeOut.Length equal to the duration of the crossfade. (Actually, I have found at least one event that returns a value for the FadeOut.Length that is not zero, but is not the correct value either).
The code below shows the script, including two lines of "troubleshooting" code I was using to stop and look at the fade length for each event.
Does anyone have any ideas as to what is causing this problem? I am using Vegas 5.0d.
/**
* This script will add regions for all events on the selected track,
* and name those regions to the event's media file name.
*
* If more than one event comes from the same media, this will result in
* duplicate region names.
*
* By John Meyer 4/11/2005
*
**/
import System;
import System.IO;
import System.Windows.Forms;
import Microsoft.Win32;
import System.Collections;
import Sony.Vegas;
var evnt : TrackEvent;
var myRegion : Region;
var RegionName : String;
try {
//Find the selected event
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
var MyFilePath = evnt.ActiveTake.MediaPath;
var extFileName = Path.GetFileName(MyFilePath);
var baseFileName = Path.GetFileNameWithoutExtension(extFileName); // Media file name for this event
var StartTime = evnt.Start;
var LengthTime = evnt.Length;
// if (evnt.FadeIn.Length.Nanos > 0) {
// StartTime = StartTime + evnt.FadeIn.Length;
// LengthTime = LengthTime - evnt.FadeIn.Length;
// }
if (evnt.FadeOut.Length.Nanos > 0) {
LengthTime = LengthTime - evnt.FadeOut.Length;
}
MessageBox.Show (baseFileName + ", " + evnt.FadeOut.Length);
myRegion = new Region(StartTime,LengthTime,baseFileName); //Insert a region over this event
Vegas.Project.Regions.Add(myRegion);
Vegas.UpdateUI();
eventEnum.moveNext();
}
} catch (e) {
MessageBox.Show(e);
}
function FindSelectedTrack() : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}