Jump to: Board index » General » Fusion

Minutes and Seconds Format for Countdown Timer?

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline
User avatar

Dave Dugdale

  • Posts: 121
  • Joined: Fri Dec 28, 2012 4:22 pm
  • Location: Colorado

Minutes and Seconds Format for Countdown Timer?

PostThu Jul 05, 2018 4:43 pm

So I found an expression for a countdown timer:

Code: Select all
Text(math.floor((10000-time)/23.976)+1)


That expression works great for counting down the seconds, however I was hoping to put that in a minutes and seconds format instead of just seconds.

Any ideas on how to format it this way, or is there an easy format expression like:


Code: Select all
Text(minutes(math.floor((10000-time)/23.976))+1)
Dave Dugdale
Learningvideo.com
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostThu Jul 05, 2018 8:32 pm

Hey Dave - maybe something like the below?

Code: Select all
:startcounter=2000;framerate=30;minutes=floor((startcounter-time)/framerate/60)%60; seconds=floor((startcounter-time)/framerate)%60; return Text(string.format("%02.f",minutes)..":"..string.format("%02.f",seconds));


just substitute framerate = 30 with required framerate and adjust the startcounter (in seconds) as per appropriate.

I didn't fully check this, so it may require some tweaking.

cheers, Okke
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostThu Jul 05, 2018 8:35 pm

whoopsie - startcounter is currently in frames rather than seconds...
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostThu Jul 05, 2018 8:38 pm

Now in seconds (adjust the startseconds)

Code: Select all
:framerate=30;startseconds=120; startcounter=startseconds*framerate;minutes=floor((startcounter-time)/framerate/60)%60; seconds=floor((startcounter-time)/framerate)%60; return Text(string.format("%02.f",minutes)..":"..string.format("%02.f",seconds));


EDIT: btw, I'm sure this can be optimized one way or another, but it seems to work!
www.ablackbirdcalledsue.com
Offline
User avatar

michael vorberg

  • Posts: 876
  • Joined: Wed Nov 12, 2014 8:47 pm
  • Location: stuttgart, germany

Re: Minutes and Seconds Format for Countdown Timer?

PostFri Jul 06, 2018 6:39 am

you can also just right click in the text field of the Text+ node and select TimeCode, in the modifier you can select which part you want to see (Hours, minutes, seconds, frames) and a frame rate

if you now animate the "start offset" you can create a countdown that goes faster in time, backwards, ...
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostFri Jul 06, 2018 7:02 am

ha! And that's of course much more elegant :-)

Guessing, I'm loving expressions a bit too much so that I forget to look at the more obvious!

I suppose the one thing that's still handy with the expression is that you can be very flexible with the formatting.
www.ablackbirdcalledsue.com
Offline
User avatar

Dave Dugdale

  • Posts: 121
  • Joined: Fri Dec 28, 2012 4:22 pm
  • Location: Colorado

Re: Minutes and Seconds Format for Countdown Timer?

PostMon Jul 09, 2018 3:29 pm

Thanks guys for helping out! I have tried both methods and if you have a minute can you watch this video to see the issues I am having?



Ok, after making this video I found that by modifying this expression to this works well:
Code: Select all
:framerate=60;startseconds=120; startcounter=startseconds*framerate;minutes=floor((startcounter-time)/framerate/60)%60; seconds=floor((startcounter-time)/framerate)%60; return Text(string.format("%02.f",minutes)..":"..string.format("%02.f",seconds));
Dave Dugdale
Learningvideo.com
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostMon Jul 09, 2018 8:32 pm

Hey Dave - glad you worked it out. What I don't understand though is that in the updated expression you use a frame rate of 60, even though your timeline is at 23.976? Are you sure the timeline is indeed at 23.976? Sounds to me that the footage/timeline is at (or close to) 60 fps?

To address a few other points in your video:

- the missing modifier info....double click on the modifier name will show all the info.
- for more info on timecode or any other node, check the Fusion 9 Tooling Reference guide. That has got a wealth of info.

EDIT: I assume in the above that your timeline fps is set the same as your clip fps.


cheers, Okke
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostMon Jul 09, 2018 8:53 pm

BTW - I typically work in Fusion standalone, and I noticed a bit of a discrepancy between Resolve Fusion and Fusion in terms of how the expression behaves. Somehow it has to do with the way the time is interpreted. I need to do some digging!
www.ablackbirdcalledsue.com
Offline

Okke Verbart

  • Posts: 126
  • Joined: Tue Jan 17, 2017 8:40 pm

Re: Minutes and Seconds Format for Countdown Timer?

PostMon Jul 09, 2018 9:29 pm

Also, I noticed a slight error in my expression which leads to the first second being "counted down" within a single frame. The below expression corrects that. Again, change the frame rate as per appropriate.

Code: Select all
:framerate=60;startseconds=120; startcounter=((startseconds+1)*framerate)-1;minutes=floor((startcounter-time)/framerate/60)%60; seconds=floor((startcounter-time)/framerate)%60;return Text(string.format("%02.f",minutes)..":"..string.format("%02.f",seconds));
www.ablackbirdcalledsue.com
Offline
User avatar

Dave Dugdale

  • Posts: 121
  • Joined: Fri Dec 28, 2012 4:22 pm
  • Location: Colorado

Re: Minutes and Seconds Format for Countdown Timer?

PostWed Jul 11, 2018 3:45 pm

Okke, thanks again for your expression script it works great now. After I am done with this video I will make a video about your expression and how I used it in my project to give back to this community for others with a similar question to mine.
Dave Dugdale
Learningvideo.com

Return to Fusion

Who is online

Users browsing this forum: brianbrook, Plasmo, szann01 and 8 guests