Copy link to clipboard
Copied
how convert time to timecode in extendscript?
for example:
1.5 sec convert to 01:15 in composition 30 framerate
Copy link to clipboard
Copied
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;