Create a timecode with expressions

Moderators: Disciple, zlovatt

User avatar
chaosbeach
Posts: 1
Joined: March 14th, 2019, 7:50 am

Hi,

I added a simple timecode to my video and now I'd like to make the numbers speed up as if there was a fast forward, and stop them, then rewind and so on as if it were a tape

this is the expression so far

function pad(str, max) {
str = str.toString();
return str.length < max ? pad("0" + str, max) : str;
}

function digits(myVal, myNumDigits, myPad) {
var s = myVal.toString();
while (s.length < myNumDigits) s = '0' + s;
return pad(Math.floor(s), myPad);
}

hr = digits(time / 3600, 2, 2);
min = digits(time % 3600 / 60, 2, 2);
sec = digits(time % 60, 2, 2);

hr + ":" + min + ":" + sec;


which works just fine, but I wish I could use keyframes to make them go faster.
or any tool, which I propably don't know yet

I am sorry if that seems like a dumb question, but I am not so well versed in code yet.

Glad if you could help me out if my idea is even possible....

thank you so much

cheers!
User avatar
zlovatt
Posts: 47
Joined: October 31st, 2016, 5:00 pm
Location: Portland
Contact:

Hey!

What you can do:
  • Create a slider on your layer
  • Animate it from 1 -> higher
  • Replace your expression with this one (below)
  • Where I wrote {pickwhip slider here}, delete that and pickwhip the slider.

Code: Select all

function pad(str, max) {
  str = str.toString();
  return str.length < max ? pad("0" + str, max) : str;
}

function digits(myVal, myNumDigits, myPad) {
  var s = myVal.toString();
  while (s.length < myNumDigits) s = "0" + s;
  return pad(Math.floor(s), myPad);
}

var slider = {pickwhip slider here};
var input = time * slider;
var hr = digits(input / 3600, 2, 2);
var min = digits((input % 3600) / 60, 2, 2);
var sec = digits(input % 60, 2, 2);

hr + ":" + min + ":" + sec;
Post Reply