Skip to main content
Participant
February 18, 2025
Answered

Getting Correct Clip Timings (hh:mm:ss:ff) from seconds and ticks

  • February 18, 2025
  • 2 replies
  • 520 views

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.

Correct answer bbb_999

I've also tried using the Time.getFormatted() method, but I'm getting an "illegal parameter" error.

 

Failing code snippet, please?

Time objects are 100% the right approach.

2 replies

bbb_999
Community Manager
bbb_999Community ManagerCorrect answer
Community Manager
February 18, 2025

I've also tried using the Time.getFormatted() method, but I'm getting an "illegal parameter" error.

 

Failing code snippet, please?

Time objects are 100% the right approach.

Kevin J. Monahan Jr.
Legend
February 18, 2025

Hi @sekar_saravanaa,

Thanks for the message and welcome to our forum. I have edited the label for your post as "SDK" so it will draw the appropriate attention to those that might be able to reply more readily. I hope that's OK. In the future, you may want to do the same, should you have more scripting related questions. I hope we can help you shortly. Sorry for the hassle.

 

Thanks,
Kevin

 

Kevin Monahan - Sr. Community and Engagement Strategist – Adobe Pro Video and Audio