I’ve run into a frustrating brick wall when using:
projectItem.setInPoint(seconds)
projectItem.setOutPoint(seconds)
…about 50% of the time the I/O points (in the source window) are set with a 1 frame error (sometimes 2 frames out). I feel like I’ve tried everything to discover what the pattern is, but it seems entirely random.
I thought it might be something to do with drop frame, variable frame rates, the clip being different from the sequence, or other oddities, but the error occurs at simple constant frame rates like 25 fps. There just seems to be no rhyme or reason to the errors (although the same error occurs consistently on certain frames).
There’s even a bigger problem with subclips, as the scripting environment thinks that all subclips start at frame 0.
I’ve tried everything, including working in ticks, seconds or frames, and converting between them. Nothing made a difference.
What I’m trying to accomplish is to set in/out on a set of clips, run a script to make smaller cuts from those source clips, and then restore the clips to the original I/O points. Got most of this working except I can’t restore all the clips to the original I/O points with this bug.
Below is a test script I wrote. It gets the current I/O positions, stores them, and then sets them back to the same clip. Half the time the values are not the same! Argh! This makes it impossible set the clips I/O accurately.
function framesToSeconds (frames, fps)
{
return frames / fps;
}
function secondsToFrames (sec, fps)
{
return sec * fps;
}
/*---------------------------------------------------*/
var projItems = app.project.rootItem.children;
var clip = projItems[2];
var fps = clip.getFootageInterpretation().frameRate;
var setIn = clip.getInPoint().seconds;
var setOut = clip.getOutPoint().seconds;
var inFrame = secondsToFrames (setIn, fps);
var outFrame = secondsToFrames (setOut, fps);
var secIn = framesToSeconds (inFrame, fps);
var secOut = framesToSeconds (outFrame, fps);
clip.setInPoint( secIn );
clip.setOutPoint( secOut );
var setIn = clip.getInPoint().seconds;
var setOut = clip.getOutPoint().seconds;