I'm looking for a way to display a timer to measure things happening during the movie, a swimming event for example.

Can I add a timer that will start once the race is started and displaying in MM:SS:MS?

I have Adobe After Effects 2014 running on my Mac.


The Timecode effect (effects>text>timecode) will add a timecode, but it's measured in HH:MM:SS:FF rather than milliseconds.

You could do it with an expression by adding a text layer, and applying an expression to the Source Text property. Below is an expression that returns what you want.

To apply it, alt-click on the stop watch for the text layers Source Text property and paste the expression in.

alt click the stopwatch

This expression includes an offset, because the time constant in AE starts at 0, no matter what your comp's timecode. So if you wanted the time on the dispay to be 0 at 1 second ten frames in your comp you'd subract 1.4 seconds (at 25 fps) from time on the first line. Or if you wanted to start the count at 1 second 234ms you'd add 1.234 seconds. Or you could precomp it if that's too hard. Here's the code to copy 'n paste:

offsettime=time //<--subtract or add a time offset (in seconds) here

//a hacky way to zero pad the end of the ms field to
//three digits, but easier than doing it numerically:
ms=((offsettime % 1)+"000").substr(2,3);

//zero pad the seconds if they're less than 10. 
//"%" is the modulus operator, aka the remainder, so at 60s it rolls over:
s=Math.floor(offsettime % 60 );
ss=s>9 ? s : "0"+s;

//and so on. Thank you ancient Mesopotamia for our weird time measurement system
m=Math.floor((offsettime / 60) % 60); 
mm=(m>9) ? m : "0"+ m;
h=Math.floor( (offsettime / 3600) % 24);
hh=(h>9) ? h  : "0"+ h;
//if whatever it is runs longer than 24hrs you're on your own

//now turn it all into a string:
hh + ":" + mm + ":" + ss + ":" + ms

note that the precision is limited by your comp's frame rate, so for 25fps the results will be just multiples of 40 ms.

Here it is applied (the red background is just the comp bg). Use normal text formatting to change the font etc (a monospaced one will work best).

enter image description here

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.