Skip to main content
Gholamreza Rezaei
Participant
July 2, 2021
Question

convert time to timecode in extendscript?

  • July 2, 2021
  • 1 reply
  • 993 views

how convert time to timecode in extendscript?

for example:

1.5 sec convert to 01:15 in composition 30 framerate

This topic has been closed for replies.

1 reply

Inspiring
July 2, 2021

You can find 'timeToCurrentFormat' here:

https://ae-scripting.docsforadobe.dev/general/globals/

 

You would need to make sure the project is set to display timecode not frames (Project.timeDisplayType), like here:

https://ae-scripting.docsforadobe.dev/general/project/#project-timedisplaytype

 

Make sure you read up on the docs about whether it calculates it as a duration or based on the project start frame.

 

This example will convert display type to timecode if necessary, make the conversion, then convert display type back if necessary.

 

var displayFrames = false;
if (app.project.timeDisplayType!= TimeDisplayType.TIMECODE) {
	app.project.timeDisplayType = TimeDisplayType.TIMECODE;
	displayFrames = true;
}
var theTime = 1.5;
var theFPS = 30; // obviously you could grab this from an active comp instead, assuming one was active

var theTimecode = timeToCurrentFormat(theTime, theFPS, true);

alert(theTimecode);

if (displayFrames) app.project.timeDisplayType = TimeDisplayType.FRAMES;