Matt Hackmann

MattHackmann

The thoughts and goings-on of some programmer dude.

Display Time Code in After Effects with Expressions

Whilst working on my current video project, I came across a need to display the current time code. Expressions are the answer, of course, so I came up with this.

txt = "";
frames = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);
f = frames % 30;
s = Math.floor(frames / 30);
m = Math.floor(s / 60) % 60; s %= 60;
h = Math.floor(m / 60);
if (f < 10) f = "0" + f;
if (s < 10) s = "0" + s;
if (m < 10) m = "0" + m;
if (h < 10) h = "0" + h;
txt = h + ":" + m + ":" + s + ";" + f;
txt

Simply attach this expression to the Source Text property of a text layer and viola!