Getting Correct Clip Timings (hh:mm:ss:ff) from seconds and ticks
I'm trying to get the correctly formatted start and end times (hh:mm:ss:ff) of clips within a sequence using the Premiere Pro scripting API. I have the seconds and ticks values for the inPoint and outPoint (or end) properties of the clips, but I'm having trouble converting them to the correct timecode format.
Here's what I'm doing:
formatTime function (simplified example)
function formatTime(ticks, fps) {
// ... calculations to convert ticks and fps to hh:mm:ss:ff ...
}
var sequence = app.project.activeSequence;
var fps = sequence.frameRate;
// ... (loop through clips) ...
var startTime = formatTime(clip.inPoint.ticks, fps);
var endTime = formatTime(clip.outPoint ? clip.outPoint.ticks : clip.end.ticks, fps);
$.writeln("Clip " + clip.name + " Start Time:", startTime);
$.writeln("Clip " + clip.name + " End Time:", endTime);
I'm using the sequence's frame rate (sequence.frameRate) as the fps value in the formatTime function. However, the resulting timecodes are not matching what's displayed in the Premiere Pro timeline. [Provide specific examples of the discrepancies, e.g., "The timeline shows 10:00:06:18, but the script returns 00:00:05:10".]
I've also tried using the Time.getFormatted() method, but I'm getting an "illegal parameter" error. [If you've tried getFormatted(), include the code you used and the exact error message.]
Could someone please advise on the correct way to convert seconds and ticks to hh:mm:ss:ff format that matches the Premiere Pro timeline display? I'm particularly interested in ensuring the frame values are accurate. Any help would be greatly appreciated.
Additional Information to Include:
- Premiere Pro Version: (Very important for compatibility issues)
- Operating System: (Windows or macOS)
- Sequence Settings: Provide the sequence settings (frame rate, time display format) if possible. You can get this using $.writeln(JSON.stringify(sequence.getSettings(), null, 2));.
- Example ticks and seconds Values: Include the ticks and seconds values for a specific clip that's giving you incorrect timecode, along with the expected timecode from the Premiere Pro timeline.
- formatTime Function: Include your formatTime function's code. This will help others identify any potential errors in your calculations.
The more detail you provide, the better others can understand the problem and offer solutions.
