Countdown Timer with Expressions After Effects CC Tutorial
HTML-код
- Опубликовано: 5 сен 2024
- CREATE A FEW SIMPLE COUNTDOWN TIMERS IN AFTER EFFECTS EASILY! | Learn to write the expressions that you need to build a very simple or very complex timer in After Effects.
👾 DISCORD: discord.me/tutvid
🏆 My Instagram: / tutvid
💰 Buy the Photoshop Course and Support the Channel → bit.ly/28NuwFy
🎯 Subscribe for Daily Tutorials → goo.gl/DN4Nln
-
In this After Effects tutorial, we’ll dive into using a single text field and create a couple of VERY simple timers to kick things off and then we’ll write a bit more complex code to create a much more realistic and functional countdown timer that you have complete control over. You can choose the duration of the countdown and simply set it and forget it! Build the code once and have a countdown menu that you can use for any project anywhere.
⚡️ written tutorial here: bit.ly/2EP1l9t
INSTAGRAM: / tutvid
TWITTER: / tutvid
FACEBOOK: / tutvid
tutvid is a RUclips channel dedicated to creating the best Adobe Photoshop, Premiere Pro, Lightroom, and Illustrator tutorials. My goal is to create the best, most informative, and entertaining tutorials on the web. If you enjoy my videos, the best way to support what I do here is to purchase my course linked above or simply subscribe to the RUclips channel by pressing the red button.
✉️ business inquiries: nate@tutvid.com
-
If you are just looking for the expression :
t = Math.floor(outPoint-time);
minut = Math.floor(t / 60);
second = t % 60;
if(minut < 10)
{
if(second < 10)
{
['0' + minut + ':' + '0' + second];
}
else
{
['0' + minut + ':' + second];
}
}
else
{
if(second < 10)
{
[minut + ':' + '0' + second];
}
else
{
[minut + ':' + second];
}
}
Thanks!!!!
thanks mate!!!
Bless you.
Bless you!
you are a legend
"CREATE A FEW SIMPLE COUNTDOWN TIMERS IN AFTER EFFECTS EASILY! "
Your definition of easy is mindblowing.
Alright, let me show you how to do this real quick. Do you have 30 minutes?
@@ChrisHanline
It.goes
00:13
00:12
00:11
00:10
00:09
00:08
00:07
00:06
00:05
00:04
00:03
00:02
00:01
00:00
0-1:0-1
0-1:0-2
0-1:0-3
0-1:0-4
0-1:0-5
0-1:0-6
0-1:0-7
0-1:0-8
0-1:0-9
0-1:0-10
it is easy. Math.floor(60-time);
You can use this code, you do not need a slider for this!
Important! To make the time go in front, you just need to remove - "outPoint-"
t = Math.floor(outPoint-time);
minut = Math.floor(t / 60);
second = t % 60;
if(minut < 10)
{
if(second < 10)
{
['0' + minut + ':' + '0' + second];
}
else
{
['0' + minut + ':' + second];
}
}
else
{
if(second < 10)
{
[minut + ':' + '0' + second];
}
else
{
[minut + ':' + second];
}
}
This one worked altho it works different. It adjusts depending on the layer size instead.... but with that said, it did work, unlike the other did even when changing to Legacy expression.
THANK YOU, for some reason the timer shown in this video didn't work properly (countdown went into negatives even though I copied the command text exactly) and couldn't go forward from zero. Yours works perfectly for what I was trying to achieve.
I HAVE BEEN LOOKING FOR THIS ANSWER FOR 2 HOURS. THANK YOU
Thanks dude!!! It worked great!!!😀
THANK YOU!
Thank you so much for taking the time to teach it and not just tell us to paste it in. Understanding how the expression was built will really help when I need to change or update it for a different project
People having problems with copy paste is because the written version in his page has a lot of wrong symbols like double quotes being different. heres the fixed version that has worked for me and my friends doing a copy and paste. BTW excellent Job and tutorial, really love this one.
rateOfSpeed=1;
clockStartTime = thisComp.layer("Timer Duration").effect("Slider Control")("Slider")*60;
clockTimeNumber = Math.floor(clockStartTime - rateOfSpeed*time);
function addZero(n) {
if (n 0 && time < clockStartTime) {
addZero(minutes) + ":" + addZero(seconds);
} else {"00:00"}
it still doesn't work for me .. 2019 version and i dont know why it wont ... it wont show anything
@@gamingmoments8097 verify that you have create the elements with the same name as the code
i pasted this in but it just says error.
AMAZING!! thank you
it says it has 1 error with the syntax.
I really dig how this tutorial is a bit on the longer side but full of useful info on the actual basics of what you're teaching. Definitely learned a thing or two!
This has been one of the best After Effects tutorials I have ever seen. You explained it in a wonderfully building way and made it clear the entire time. Thank you, this was extremely helpful!
- Make a Text Layer and put "00:00"
- Then add Slider Control
- Add this in source text:
slider = effect("Slider Control")("Slider");
sec = Math.floor(slider%60);
min = Math.floor(slider/60);
function addZero(n) {
return (n < 10) ? "0" + n : n;
}
addZero(min) + ":" + addZero(sec);
THIS! hahahahaha
Thanks its working!
doesn't work. time doesn't go down
@@cwgunn you must key frame and keep comp in 1 fps. Then import that comp (which is only text) and reverse the comp.
loop of thanks to you!
Bro I cannot tell you how helpful this was. I was loking for tuts to create a template like this and this is byfar the most detailed tutorial. And thank you for sending this. For the benefit of everyone using After effects 2020. I am adding the expression that worked for me:
rateOfSpeed=1;
clockStartTime = thisComp.layer("Time Duration").effect("Slider Control")("Slider")*60;
clockTimeNumber= Math.floor(clockStartTime-rateOfSpeed*time);
function addZero(n){
if(n 0 && time < clockStartTime){
minutes + ":" + addZero(seconds);
} else {"0"};
THANK YOUUUUUU!!!!
2021 experience... I only had 2 hiccups. (and I have very little experience with expressions)
1. I'm sure this is a classic thing to watch out for, but if you happened to copy-paste the code from the blog in the description (or anywhere else), the quotation marks may be curly instead of straight, and that creates an error every time. I copy-pasted from his blog to be quick, and had to go in and remove and re-type all instances of quotation marks within the AE code editor.
2. I also had to use the if/else statement replacement from Giselle Thomas below.
Now it's working for me!
Also, if you didn't watch the entire video and don't like the extra zero on the minutes side, just leave the last if statement as:
if (clockStartTime > 0&& time < clockStartTime) {
minutes + ":" + addZero(seconds);
} else {"00:00"};
You're a lifesaver!
Thanks. This is exactly what I needed.
Thanks! for those who want the code, here it is! X)
rateOfSpeed = 1;
clockStartTime = thisComp.layer("Timer Duration").effect("Slider Control")("Slider")*60;
function addZero(n) {
if(n 0 && time < clockStartTime) {
addZero(minutes) + ":" + addZero(seconds);
} else ("00:00");
great tutorial ! thanks ! Made to do something similar instead: 3 sliders (hours/minutes/seconds) and source text (option "-/+" in currTime determines if its a counter or just stoper...
function fixZero(n) {
if(n
THIS WAS A FANTASTIC TUTORIAL. Love how you break down the thought process!
Thank you for all of that, I love your vids. I hope this is okay, but I pasted the code below for easy acces for everyone...
RateOfspeed = 1;
ClockStartTime = thisComp.layer("Timer duration").effect("Timer length")("Slider")*60;
function addZero(n){
if(n 0 && time < ClockStartTime){
Minutes + ":" + addZero(Seconds);
} else {"0"};
Yeah just follow the first 6 minutes and drop this code into the source text and youre done
you typed the code wrong but ok
you are a god tier human being
@@benjins1751 Haha! No no, I am merely a message boy. Tutvid is the real champion.
thanks so much! this worked except I had to update this line for some reason.
ClockStartTime = thisComp.layer("Timer Duration").effect("Slider Control")("Slider")*60;
if someone is getting error in AE 2018, then you should change the if condition statement to simplified one or full version like this :
function addZero {
if(n
Doing exactly this and putting in a line break (or 'enter' on your keyboard) made this function work. Thank you!!
Thank you this worked!
function addZero(n) {
return (n < 10) ? "0" + n : n;
}
This will work for the newest verison of AE
@@MrBoost92 THANK YOU! I have been struggling for the last hour with this.
@@MrBoost92 Yes thank you this is what I needed for AE CC!
This is the first time I have even come close to understanding how Javascript works. It's like Javascript essentials. Nice one :)
This was a great walkthrough video! I felt like I was in a lecture lab *in a positive way*. Thank you!
If you add
clockTimeNumber = Math.floor(outPoint-time);
the timer will countdown based on the length of your text layer ;-)
The addZero function is hot. Thanks.
thats useful :)
In a scenario where one is editing cut scenes eg Timer starts with 15 min, next scene 7 minutes, third scene 3 min, it's easier to use slider to adjust the values than to change the length of text layer ;)
If anyone is getting an error on the function addZero portion, I found a fix on adobe's community site.
function addZero(n) {
return (n < 10) ? "0" + n : n;
}
Ran into the same issue. Thanks
I had the same problem fixed by your contribution, thanks!
Same problem this helped thanks!!!
Thanks a LOT!!!!!
THANK YOU!!
I think it's going to take me some time to digest these lengthy expressions. I'll keep watching your tutorials about expressions. This is truly amazing. Thank you for this. I'm going to rest my brain now.
Great video.... I was looking for the easy way but since I couldn't add the zero I ended up watching your video. NO REGRETS! your video is beautifully explained! thank you!!!
I don't know what after effects or expressions is, but I keep listening to this cause the audio is so good! Thanks
Thanks so much for explaining the coding here!
I don't know how to thank you. The expression of after effects is so sweet.
Bro you’re sense of humor is impeccable I friggin love it! 😂 great tutorial as well!
I got your video in the morning when i opened my eyes. It feels very good. You never forgot to upload videos. good job .. thank you
I'm trying over here! Haha. Thanks for watching!
At first I was like, dang this video is so long. Then watched it and realized how well you explain it! Thank you for all the context. I feel like I understand expressions better now and I'm definitely subscribing!
Thanks, Mel! Glad you enjoyed it!
he is the perfect programming professor we need
Never stop making tutorials!
for anyone facing errors, try this ::
startmin = 5
//minutes
mins = Math.floor((startmin*60 - time)/60);
secs = Math.floor(startmin*60 - time)%60;
if (secs < 10) secs = "0" + secs else secs = secs
"0" + mins + ":" + secs;
Ps: use the same if/else statement for minutes if your countdown is more than 10 minutes..
and m jst a begineer, so feel free to modify n reply. :)
Yes that code was garbage. Didn't work. Took 30 minutes worth of notes to only have it now work.
Thank you
Worked wonders for me! Thanks!
Gonna adjust this and place it in an Essential Graphics template and share it with the time, maybe add a color changer in there so they don't have to keep returning to me for a newly rendered timer.
Thank you! That's awesome!
I used to watch your Photoshop and Dreamweaver (you did those too, I think?) videos years ago and was thrilled to find that you're even doing AE tutorials now. You are a gem! Thanks so much for sharing your knowledge with us!
Best Countdown Tut on RUclips!
love you, you save my work. cheers.
Best Countdown Tutorial Ever
Excellent Video!
I know this an old video, and y're probably over getting gushy comments, but your rapid fire, no-nonsense approach is awesome. I was horrified that a 'simple' AE timer was not available on the stock-video sites that I use. However, being able to make my own was PFA! (even if I did have to use the new Java syntax). The Darwin Rides channel thanks you!
If you are using AE 2020, the "else return" input must be written as a new paragraph bellow "if ( n < 10)" or else AE will declare it as an error.
Cheers! Thanks for the tutorial!
Great tutorial!!
HUGE help, very thorough and easy to follow. I also appreciate how you a step or two off path to explain why things work the way they do. Thanks!
THANK YOU! SO MUCH!
Awesome. Thanks.
Thanks, Nat!
This is one of the best tutorials I've ever seen - fast, concrete and clear.
It is the first time I use expressions in AE and it works!
Incredibly helpful and informative. Your way of demonstrating and explaining helped me understand the how and why of what you were doing, and made me more confident to try to execute it myself. I now have a functioning countdown timer for the video I'm working on, and I learned some things too! Thank you so much for the great content.
Amazing tutorial! I have one issue tho. Getting that annoying shifting from left to right as the numbers have different widths.
Are you using a monospaced font? Any way you know off turning off proportional spacing on normal text?
Why the hell creating a simple timer should be this hard?
Same bro I thought there was an effect to apply or smth
Yeah this is more coding than video editing lol
@@jorgemonzon7550 Well if you are always only looking for "an effect to apply or smth" in your Life youll run into dead ends regularly. Something things arent as easy as you want them to be. But then the only thing that helps is getting through them. Also you can literally copy his code... Is that so difficult?
@@TheKlikluk yeah well copying the code is not working for me as I keep getting syntax errors so yeah its difficult
@@jorgemonzon7550 there is an effect called "number"
you give the best tutorials, by far. SO easy to follow!!! Thank you so much, please keep doing what you're doing!
Excellent tutorial!!! I chose to follow the video and write it as you were teaching and it works perfect. It really helped me to understand what I was doing. I did turn on Legacy ExtendScript prior to writing the expressions just in case. I am using CC2019. I definitely will check out more of your videos. Thanks again for the great job in explaining this.
Phenomenal. Thanks so much!
Extremely helpful. Thank you for taking the time to make this video!
the best timer tutorial out there!!! I knew nothing about expression, but I followed along and understood what you showed us. Nice one!!!
This tutorial was fantastic. I don't do much code/ expressions, but I think this was very easy to follow and understand. Wouldn't be able to remember it all by heart for later, but at least now I get what goes into it.
Thank you!!!
Great tutorial. One alternative that may be useful to some... If you want the timer to always be the length of the composition, set your clockStartTime variable to thisComp.duration (this is the value of the composition length in seconds) and adjust your text frame length accordingly.
Thank you Tutvid! Excellent tutorial - big help - I'm not an "expression" user but I feel more confident now after watching it! Thank you again
thank u sooo much!!! OMG I've looking for that so long! so many video watched, so many time wasted! only this helped me. THANK YOU!!!
thanks man!!
The correct function syntax is this:
function addZero(n){
if(n
An amazing tutorial. My only issue in the end was a syntax error with the 'else' statement. I fixed it by pressing enter and having the 'else return n;' on a second line.
Thank you so much for that! I was pulling my hair out over that one! Legend x
Super nice explanation! I hope it brings me closer to learn how to think of my own expressions one day!
Nice tutorial
Thank you! Easy to understand! Appreciate your help. Subscribed.
Thanks. This was very useful and well explained.
Thank you :D
Really great tutorial ! It’s the better way to learn !
Perfect tutorial!
One of the best and funnest tutorials I've seen so far, especially considering not the most fun subject in the world!
Thank you so much for doing this! You're incredible!
great so great tutorial, thak you so much Tutvid, greetings from Colombia, South America
Thank you! This is awesome and your explanation is SUPER good!
Awesome, simple, direct, and fast
You are a God. Thank you for the best video on the subject.
Awesome tutorial, saved me so much time. Thanks!
Hey I just stumbled on your channel. And in as much as this one put the flame to my brain cells, I'm really grateful especially that this is something Ive needed to make for a while.
thx a lot man, your video helps me
Works great! Does anyone know how to keep the characters from shifting when the number sizes change? I want everything to stay aligned with the semicolon.
It's probably not the way to do it but my guess would be to separate the minutes and seconds into 2 pieces of text (mins right aligned and secs left aligned) with the correct edit of this full expression across both text layers
Easiest solution is a monospaced font (eg. Roboto Mono)
This is seriously good and helped me understand a lot!
thanks for this. i'm good with programming but I didn't know how easy it was to do it in AE!
2021: this was what i had to change the code to. I tried the other mentioned methods of changing to legacy script but that didn't help me. This is a combo of a lot of different commentor's fixes plus my own to keep it stopped at 00:00
rateOfSpeed=1;
clockStartTime = thisComp.layer("slider").effect("Slider Control")("Slider");
clockTimeNumber = Math.floor(clockStartTime-rateOfSpeed*time)
hour = Math.floor(clockTimeNumber/3600)
minutes = Math.floor(clockTimeNumber/60)%60;
seconds = clockTimeNumber%60;
function addZero(n){
if(n
Is there a way to link another animation (like say a trim path animation on a shape layer) so that the trim path automatically changes with the timer silder input?
Quite helpful. Thank you!
Is there a way to let the timer start after 3 seconds so I can let it animate in?
Thank You very much Sir.
I'm never deleting this file!
thank you
Thank you - it works!
Thank u!Great tutorial!
how to keep the numbers align when the number of character changes?
i have this question too!
@@julianheninger1174 me too!
Awesome!
Thank you very much!!! Do you have a hour countdown (like a 3-6 hours one 00:00:00)?
This code works for me (2020)
rateOfSpeed = 1;
clockStartTime = thisComp.layer("timer duration").effect("Slider Control")("Slider")*60;
function addZero(n){
if(n
Great! It works! Tutvid, you made my day! This is one of ten times when I coded something myself!!! And it works!! Yohooooo!
Fantastic resource. Thank you so much!
You only need to create a text layer and add the timeToCurrentFormat() expression in SourceText, then you can mask it to remove frames or whatever you don't want
Incredibly helpful and insightful. Thank you for the terrific video!
Thank you! Works perfect!
How to add the milliseconds tho?
Expression of Milliseconds=(ClockTimeNumber*1000)%1000
So useful! Thanks a lot
Thank you very much! This helped me a lot
Thank you, clear and easy
awesome and so easy the way you explained it :) thanks!