FadeOut.Length incorrectly returns zero

johnmeyer wrote on 5/13/2005, 12:28 PM
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.

/**
* 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;
}


Comments

pelladon wrote on 5/14/2005, 8:54 PM
So in your *.sub file, the values in it are incorrect? Like an entry like 00:00:04:00 , 00:00:04:00, that is two consecutive same values on the same line?
johnmeyer wrote on 5/14/2005, 9:12 PM
So in your *.sub file, the values in it are incorrect?

Yes, but the values are incorrect because my script creates overlapping regions, but only on a few events. The problem is not in the export of these regions to the sub file (i.e., the Sony script works just fine). Instead the problem is in the way my script generates the regions. It sure feels like a bug of some sort because 95% of the time the script works correctly, and then every once in awhile, it returns a FadeOut length that makes no sense at all. Sometimes it is zero, when there is a fade of 20-30 frames, and other times it returns a fade length that is not zero, but is far less than the actual fade length.

I've had to proceed with the project and manually fix up all the errors, but I'd sure like to fix this for the future.
JohnnyRoy wrote on 5/16/2005, 11:13 AM
Sure sounds like a bug to me, especially since the script works some of the time and not others. I would send the veg file that has the problem to Sony and have them try and repro the problem.

~jr
johnmeyer wrote on 5/16/2005, 1:54 PM
When I get back in town at the end of this week, I'm going to do that.