Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Messing with Dan’s Universal Clock expression

  • Messing with Dan’s Universal Clock expression

    Posted by Spence Padilla on March 3, 2008 at 5:22 am

    long time lurker, first time poster… (and first timer with expressions).. thanx to all of you who’ve helped me and not even known it.

    just looking for opinions on how I accomplished something:

    I’m working on a project that called for Dan Ebbert’s universal clock expression; I needed to be able to specify a particular starting time that was non-standard(66 Hrs.) This exp did the trick; it was just math for that part. But I also needed to display frames along with the rest of the time units (for stylistic reasons the time starts at 66:06:06:06)… so I started butchering Dan’s expression to do this. It’s not terribly elegant:

    Dan original expression can be found here: https://www.motionscript.com/design-guide/up-down-clock.html

    and here’s its remains after I was done with it:(changes in bold)

    rate = 1;
    FrameRate = rate*30;
    clockStart =237966;

    function padZero(n){
    if (n < 10) return "0" + n else return "" + n } clockTime = clockStart + rate*(time - inPoint); clockTimeFrames = clockStart + FrameRate*(time – inPoint);
    if (clockTime < 0){ sign = "-"; clockTime = -clockTime; }else{ sign = ""; } tFr = Math.floor(clockTimeFrames);
    t = Math.floor(clockTime);
    hr = Math.floor(t/3600);
    min = Math.floor((t%3600)/60);
    sec = Math.floor(t%60);
    fr = Math.floor(tFr%30);
    sign + padZero(hr) + “:” + padZero(min) + “:” + padZero(sec) + “:” + padZero(fr)

    Basically it adds a computation alongside everything else to output the frames at 30 times the base rate (simulating 30fps). It works(ish) for what I need it to do, but I was wondering, from the more experienced, what the more elegant way to do it would’ve been. or other ways to do this at all… and if anyone could tell me why this expression skips one frame when displaying the 999th frame, that’d be great, too. 🙂

    thanx to all again,
    sjp

    Dan Ebberts replied 18 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    March 4, 2008 at 2:55 pm

    Something like this should work:

    clockStart =237966;

    function padZero(n){
    if (n < 10) return "0" + n else return "" + n } clockTime = clockStart +time - inPoint; t = Math.floor(clockTime); hr = Math.floor(t/3600); min = Math.floor((t%3600)/60); sec = Math.floor(t%60); f = Math.floor((clockTime%1)*30) padZero(hr) + ":" + padZero(min) + ":" + padZero(sec) + ":" + padZero(f) I'd guess that the dropping of every 1000th frame must be a 29.97 vs 30 fps artifact. Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy