ADVANCED: Loader Bar Countdown After Effects Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
(magical jingle) Well, hey everybody. Welcome into Adobe After Effects tutorial, brought to you, as always, by tutvid.com! Today, we're going to take a look at creating a really cool loader bar. Which, will not only be the animation moving across the screen set to whatever duration you choose; but also, a percentage loader showing 5%, 16%, 27%, and so on, and so forth. But also, a countdown timer showing you in minutes and seconds how close you are to completion. This can be a loading bar effect that you can use for live streams. Whether it's YouTube, Twitch, whatever. You can use it for all kinds of things, that's what I'm trying to say. I think it'll be a really cool thing, and we're going to have a ton of fun checking out a bunch of different expressions here in After Effects that I think you just might like. They're really cool. Now, if you do enjoy this tutorial, make sure hit that little, red button there, and subscribe to my channel, so you never miss any video tutorials in the future. Let's jump into After Effects now, and check this thing out. Alright, well here we are in Adobe After Effects and the first thing I'm going to do is create a new composition. You can name it whatever you want. I'm going with 2560x1440 for my width and height. I'm going with a frame rate of 30 frames per second. These are important because we're going to be working with specific sized objects, and the frame rate is going to have to do with some of the expressions that we're writing. So, a frame rate of 30 frames per second; and then I'm saying, give me a duration of two minutes. So, that's what I'm rolling with. Background color, it doesn't really matter. I'm going to hit OK. And what I'm going to do here is, drag in an image and quickly create this blurred background. There's a link, by the way, to this free stock photo that I'm using in the description of this video. Now that we have that, I want to go ahead and create the elements that we're then going to use expressions to animate. But, we're definitely going to be using the expressions. So, the first things we want to do is create a couple bars. So, I'm going to grab my rectangle tool. I'm going to drag out a rectangle. Any old size. And what I'm going to do is down here in my layers area, I'm going to say, open up the contents. Open up rectangle. Open up rectangle path; and here, I have this size area. I'm going to unlink the proportions, and I'm going to say, look, I want you to be 1,520 pixels wide, and 40 pixels tall. So, a nice, little thing going on there. And then up here with fill, I'm going to say, look, get rid of the fill. Hit OK. And then with the stroke, I'm going to say, give me - yeah, we'll go with a nice, light teal stroke. That's cool. Two pixels is fine for the size, and then using my align panel over here, I'm going to align to the composition. Vertical and horizontal centers, great. Now, you can see my little center anchor points out of whack. You can hold down your CMD+OPT keys, that's CTRL+ALT on the PC, and double click on the pan behind tool. It'll just re-center that bad boy up right there in the middle. Alright, I'm going to select this shape layer. Hit the ENTER or RETURN key, and we're going to name this "border," there we go. And we're going to make sure we deselect it. So, grab your selection tool, and deselect. Now, that we have the border, I'm going to grab my rectangle tool and I'm going to draw out another rectangle. It can be any old size because we're going to go, once again, to Contents>Rectangle>Rectangle Path, open that up, and here under size, I'm going to unlink the proportions. And we're going to set this to 1500 wide by 25 tall. By the way, notice I've got a blue fill. So, that's getting rid of the stroke and setting a blue fill. You can really pick whatever colors you like. And what I want to do, is reset my anchor point to the center of the shape. So, I'm going to hold down CMD+OPT, that's CTRL+ALT, and double click my pan behind anchor tool. And there we go. Now, I'm going to align this to the center of my document. Align horizontally, align vertically. I will grab my zoom tool, and I'll zoom in on this a little bit, and what I want to do, is move my anchor point over here to the far left. And you may need to deselect and reselect. You want to see what looks like maybe a slightly bigger anchor point there. And we'll grab our pan behind anchor tool, and I can click that anchor point. Hold down SHIFT, and even hold down the CMD/CTRL key, you can see that it's going to snap right to the center left exactly where we want it to be. The reason we want it to be that way is because this loader bar is going to begin here on the left and crawl across the screen. Alright, I'm going to name this. I'm going to hit ENTER/RETURN and I'm going to name this "fill." By the way, sorry if I'm speeding through this. While it's technically necessary to have this for the tutorial, it's not really part of the tutorial. So, I'm just flying through it as quickly as I can here. Alright, next we're going to grab the text tool. I'm going to type out, I don't know, "27%," something like that. And I'll commit the change. CMD+RETURN, that's CTRL+ENTER on the PC. I'm using the Coco Goose font, and I'm going to say, let's bump that up to 100 pixels, just like that. I'm going all caps, that's fine. And tracking at 25. Whatever, no biggie. And then, maybe I'll make this text white. So, we'll go white with this text and the other important thing that I'm doing here with text... under the paragraph panel, I have it aligned, or centered, I should say, to the middle. So, - well, centered to the middle, if that's not redundant, I don't know what is. It's centered. The text is centered, is what I'm trying to say. And then I'm going to align it horizontally and then I'll grab my move tool, and I'll nudge it down, down... eh, maybe something like that. That looks good. And last, but not least, we'll select that text and we'll duplicate it. CMD/CTRL+D. And we're going to nudge it downward using our down arrow key. Something like that. I'm going to go back to my character panel, and I'm going to reduce the size to 60 pixels. That's great. And I can zoom in on this text. And let's call this "time remaining," bing! and we'll say five minutes and 27 seconds, because we have 27 already. So, this will be our little time remaining clock. Right? That makes sense. Something like that I think is cool. And once more, also, by the way, this text is centered as well. So, there we go. We have created the pieces of artwork that we need to go in and begin writing the code to make all of this work. Are you excited? Because I'm excited! So, the first step is, we need to get a value, and we want it to be easy to set this value. And this value is going to be the time which it takes for our loader to complete. So, if you know the intro for your live show is five minutes, we can punch that in and you'll have this stuff working in conjunction to count down from five minutes while the loader bar and the percentage climb across the screen. So, I'm going to right click and I'm going to choose new. I'm going to choose null object; and I'm going to select that null object. Hit ENTER/RETURN here in the layers area, and I'm going to call this "input duration," right? Just to remind us if we're saving this as some kind of template. And here with this input duration null object, I'm going to go Effect> Expression Controls>Slider Control. Now, this might seem crazy, but the nice thing about this slider control, it's an easy way to get a number. And maybe someone who doesn't know how to write code and use After Effects. You can show them where the effect controls panel is, as long as they select input duration, they can come here to slider control and say, I want this to last 300 seconds. Which, if my calculation serves me correctly, is five minutes. And this, if we write all of our expressions correctly, everything will automatically work to make this a five minute countdown, load up, percentage loader bar. Right? But we're going to keep things simple here. Let's stick with just 60 seconds. Let's go with a straight minute. So, here's where things get fun. Let's go ahead and begin first - I guess let's write the code to make the loader bar move across the screen. So, let's come over here to fill, because fill is what we want to affect. I'm going to hit the little twirl down menu here. Let's not use the size here within the path. I'm going to collapse that. I'm going to use the scale in the transform area. So, I'm going to ALT/OPT and I'm going to click right on that little stopwatch - bing! - and it's going to open up my expressions editor. Now, before I do anything else, I'm going to uncheck the constrain proportions little chain length there. The first thing I want to do, is grab that value we have in our input duration. So, I'm going to select input duration for a quick second, and I'm going to use this little twirly thing here, the pic whip, and I'm going to drag it up and drop it on the slider. So, basically, we are stealing whatever the value of this is. We're taking that information and this is the bit of code to say, hey, go find that thing on the input duration layer. We're looking for an effect. Oh, yeah, it's the slider control effect, and it's this one called slider here. Alright, so what we're doing is, we want to create what's called a variable to hold this information, the fact that it's 60. So, I'm not going to call this "temp," I'm going to call this "duration." Sorry for my stupid dock appearing. I'm going to call this "duration" because that makes sense to me. Whenever we type the word "duration," it is going to equal whatever this slider is set to. So, we need to create now, another variable. I'm going to hit ENTER/RETURN a couple times, and I'm going to call this "bar width," just like that. And I'm going to say that bar width is equaled to something called a linear expression, and here's how it works... It's probably easier to write it out and then I'll explain it. So, we're going to create an open and closed parenthesis. And the first thing we're going to write is "times." So, this is if we're at ten seconds, this is going to equal ten. It's one of those things here in After Effects that just is what it is. So, we're going to say time. And then we're going to choose two numbers here. So, we're going to say between a time of zero and a time of duration. So, now, remember, "duration," we have that set to 60. So, basically what this is saying is, linear between the time of zero frames and 60, out here, the one minute mark, we want you to output or match numbers across that. And what we want you to do, is match zero and one hundred. And then I'm going to move out here to the very end. I'm going to throw a semi-colon onto the end of it. Now, what exactly does this mean? Well, basically what we're doing is we are saying, when time is at zero, this number is equal to zero. But, as time moves closer to wherever duration is, seep all the way up to one hundred, and when you finally arrive at "duration," which is at 60 seconds, you should also arrive at one hundred. Complicated? Yeah, maybe a little bit. But here's how we're going to use this. I'm going to move down a little bit, and now all I'm going to do is create open and closed square brackets, and in here, we're going to input the width and the height that we want for our scale to take place. So, I'm going to say, look, I want the width to be "bar width," right? If the width is going to 1% because we're very close to zero seconds, that's what it's going to be. And the height, that's going to remain at one hundred. So, bar width, comma, and then a one hundred. And we can leave it at that. We trigger no errors. You can see, the fill completely disappears, and as I scroll through this, you can see here, I bet you when I get to about thirty seconds, yeah there we go, we're about 50% of the way through. And you can see here, the scale for the width. We're right at 50%. Very, very cool. And the nice thing about this, is we never have to change this code now. If we decide we actually want the bar to take two minutes, we set this to 120 seconds, and now look at this. Now, automatically, see we have to scroll all the way up to two minutes here before it fills up. When we're at one minute, that's when the bar is at 50%. See that? Very, very cool. Let's go ahead and make our 27% become a percentage that moves in correlation with the loading bar. So, here with the 27% text layer, we're going to open up text. And here, source text is what we want to edit. So, OPT click that; and, once more, we want to get that duration variable. So, I'm going to select input duration. I'm going to grab the pick whip here for the text, and I'm going to say, yup, give me that. There we go. I'm going to pull this down a little bit so I can see it. And we're going to say, this whole thing duration equals that. Great. And then we really just need one more line of code. By the way, you can see, we're picking up duration which is equal to 60, and our text changed to 60. There's no animation going on here, it just knows that that's what the text should be. In fact, if I typed down here, in parentheses, "120," the text just changed it to 120, because we're basically saying, look, the source text should be equal to 120. I want to use another linear expression here. So, I'm going to say linear, and then I'm going to place an opened and closed parenthesis like that. Once more, I'm going to say - I'm going to track time - and I'm going to say, look, begin at zero and go to the duration variable. And once more, we're going to go zero to one hundred. Then I'll put a little semi-colon there on the end, and let's just deselect. And let's just watch what happens here. So, you can see here at zero, when everything is at 0%, we have a big, fat zero. Now, our slider is saying 60 seconds. So, at 30 seconds, this number should be fifty if our math is lining up correctly. And sure enough, you can see it's 49.94444. Now, I don't know about you, but usually when you see a loading bar, it's a clean "49%, 50%, 51%." You don't see 8,000 numbers after a decimal point. So, here's how we're going to fix that, we apply what's called a math.floor. So, we're going to say, math.floor, so, what we're doing here is we're taking this number and rounding it down to the nearest number; and then an open parenthesis and we're going to loop this entire linear expression in parentheses. So , these two outermost parentheses are for our math.floor. So, this is saying, look, this whole linear nonsense that you've got going on in here, whatever that number outputs to, boop! just go ahead and round it down the nearest number. Alright, so I'll deselect that and now you can see we have numbers, right? Nice, clean, fresh looking numbers. But we have a problem... we don't have a percentage. So, here's what we can do, we can add a percentage here in our expressions. So, we can go space add plus, and then in quotes, I'm going to do opened and closed double quotes, and then I'm just going to give the little percentage marker there. And there we go, now we have 0%, 5%, so on and so forth, all the way up. Again, the cool thing about this is it's linked to this slider control. So, if we say 120 seconds for two minutes, you can see now it climbs much more slowly; and all we have to do, is change the time here in our slider. Now, we're going to tackle the most difficult and complicated of these. And that's making our little countdown timer here with time remaining. So, let's open up our time remaining layer. Open up text, and open up source text. Once more, we're going to grab that variable - or, create that variable, I'm sorry. So, with the pick whip here we're going to go up, and say, give me that number from the slider, and I'm going to make this. I'm going to pull my expression window out a little more because we're going to need some room. Once more, I'm going to say, yup, duration equals this comp dot layer, yadda yadda yadda yadda yadda. Then we'll go ahead down a couple lines. And what I want to do here is define another variable. In fact, well, yeah, keep it clean. I'll give you some space here. I'm going to call this variable "countdown," and I'm going to say that this is equaled to duration minus time. So, this is flipping our duration variable around. What exactly is this doing? This is saying that countdown is equaled to duration, which is 60, minus wherever the playhead is. So, if the playhead is at five, you can see here, that that number being output is about 55. And 60 minus five is 55, right? So, we're essentially flipping this around and saying, look, now we're at 60. Down here we're at 16 seconds in theory left. There's how we're flipping that around. But again, we have that decimal issue. So, what we're going to do is we're going to say, countdown equals math.floor, and then here within the parentheses for math.floor, we will leave our duration time. And now we'll have a nice, clean, second countdown. Now, it doesn't look much like clock, and you obviously run into issues if you go up to something like a hundred seconds, because then you see a hundred seconds; and that doesn't allow people to see, "Oh, this thing is starting in a minute and forty seconds." You don't think that when you see a hundred seconds. So, we need to build a little clock here. And we'll do that by creating some more variables. So, let's create a couple more variables. I'm going to call the first one "minutes," and I'm going to say, minutes equals math.floor, right off the bat, because I know I'm going to want math.floor. Opened and closed parentheses, and what we'll do is we'll say, that countdown number divided by 60. Alright? And I'll throw a semi-colon on the end of that. That will be our number of minutes, and then seconds is going to equal countdown, and then I'm going to use what's called a modulus operator. This is the percentage symbol. And I'm going to say, countdown percentage 60, and then a semi-colon. So, basically, what we're doing is, with the division it's pretty obvious. We're dividing our countdown by 60. Which, basically, if we can fit one unit of 60 in there, there's one minute. Two units of 60 fit in there? There's two minutes, and so on, and so forth. But this little modulus business down here, what that's doing is taking the countdown number, which is going to be the number of seconds left, and it puts it in a number of 60 loop, if you will. So, it'll climb to 60, and then it'll reset itself. So, it's going to create this looping constraint that constrains our seconds within 60 as you would see on a second countdown. So, it would say, oh you have a hundred units? Well, that's going to be... I can climb up to 60 and then I gotta go up to 40, and that will equal 100. You'll see exactly how that works with the seconds in just a second. No pun intended. So, let's see how this works. We can output here, let's just say something like, let's go minutes. Right? We want to output minutes, plus opened and closed double quote. And we'll throw a straight colon there in the middle, and then we'll say plus seconds. Right? And that will now be output; and you can see, it's saying one minute and forty seconds. That is 100 seconds. So, you can see, our minutes variable is there, and then we're adding that little colon there in the middle, and then we're affixing to the end of that second. Now the problem with this, as I play through it, is you can see here when I get down to a minute and three seconds, I get what looks like a ratio and not a minute counter. We're going to fix that in a moment, and also with seconds when we get down below ten seconds, that also doesn't look all that great. But it's working the way it should, it's identifying and saying, look you've got a minute and forty seconds of time remaining before this program begins, or whatever it may be. So, let's go ahead. I'm going to reset my slider back to 60, just for the sake of this. Yeah, I'm going to leave it at 60 and we'll see how this works. I want to add the zeros. So, let's create a function to add the zeros and then there's going to be one more issue we have to tackle. I'll show you how that works. So, what we'll do here, is between the minutes seconds variable, and where we output our data, I'm going to create a function. So, I'm going to type the word, "function," and the name of the word function is going to be, "add zero." I actually cover how I use this function in another tutorial, but hey! we'll cover it here, as well. I'm going to say add zero, and we're going to return variable N. So, I'm going to use the letter 'n' in there, it can be - whatever, you can write "Nostradamus," if you want. But I'm just going to write the letter 'n' to keep it short and concise. Then I'll going to say, open curly bracket, ENTER/RETURN a couple times. Close curly bracket, and then move up within this function. I hit the TAB key to indent here so it looks nice. Now, this might look like a total foreign language to you, but hang with me here. I'm going to write "if" and then SPACE, opened and closed parentheses. If the number that is going to fill in 'n.' So, if 'n' is less than ten, I want you to do something. I want you to return the number zero, before you display the number, plus that variable 'n.' Now, if 'n' is greater than ten - so I'm going to say "else," right? If that's not the case, "else" simply return whatever number is that variable 'n.' This is going to make a little bit more sense in a second; but this how this is going to work. If you've never done this before. It's really, really difficult to conceptualize what's going on. But write it out and as we make it all work, it, hopefully, will make a little more sense in your mind. So, here's what we'll do. I can deselect that. We've got no errors. Nothing's changed. So, let's change some stuff. Number one, let's add time remaining before our time and then I'll show you how to add the zero. So, what we can do - this bit of stuff that's being output, we can output a string, which is just regular, raw text. You can see there, that that colon is just raw text, as long as we wrap it in parentheses - not parentheses, quotes. I'm sorry. - I can say, opened and closed double quotes. And I'll say time remaining, colon, and then I'll add a space, and then after this, I'm going to say, plus minutes, plus the colon, plus the seconds, and you can see here now, it says time remaining, and then it's the one and the zero. We haven't added the zero. So, what we want to do here, is we want to take this function. Add zero, and we want to place it before our seconds variable. So, I'm going to say add zero. Add my add zero function there. And I need to replace the number, the letter, the variable 'n.' So, I'm going to say open parenthesis, and then I'm going to close parenthesis around seconds. So, seconds now becomes 'n.' So, imagine this with seconds in there, right? If seconds are less than ten, return or display here, with seconds is zero, as well as whatever the number for the seconds are. So, if it's three seconds, it's going to say, "1:03," right? But if the seconds are greater than ten, and it's like 26, or 27, just show the 27. We don't want a zero. So, this should work. And you can see, boom! We already have a zero added on there. So, if I go ahead and plop my way through this, you can see there we go. Zero colon, zero eight, instead of just an eight. So, we added that zero. You could add the same before minutes. But I don't think it's necessary. I think it looks nice and clean with one minute, or two minutes, three minutes, four minutes, whatever. In fact, to test the time, maybe what we should do is bump this back up to 300 seconds, and see if it automatically goes to five minutes. And there you go. It went to five minutes. You have everything working in unison. Now, there is a little problem here. Let's set this back to 60 seconds. When we get out here and we get past to 60 seconds, we've got this negative number nonsense happening. So, what I'm going to do, I'm going to say "if." It's an if/else statement. If and the condition is, if that variable duration is greater than zero, right? So, basically, if the time is out here beyond zero, and the double ampersand is really "also," - both of these things have to be happening at the same time. - and time is less than the duration number. So, if we're at 45 second mark, time, which would be 45 seconds at that point, is less than 60 seconds, which is our duration, right? So, if that's the case. If we've gotten off the line, and we're still less than where our animation, our timer, our loader should complete, then go ahead and execute this whole thing, where you display these numbers. So, I'm going to paste this into here, there we go. So, if that's the case, display that. If that's not the case, so now, here's where the else part comes in, after the closing curly bracket, write "else," and then opened and closed curly brackets. If that's not the case, then we're going to display opened and closed quotes. We're going to say, time remaining, colon, space, and then I'm going to say, zero, colon, zero zero. Alright, let's deselect this. We don't have any errors happening, and we can quickly scroll through this; and let's see what happens when we get to the one minute mark. Boom! Time remaining, zeros across the board. We're at 100% completion. The fill has completely filled up, and there you have it. That is how you create this nice, and I guess we can call it advanced, because we have three separate pieces of artwork, with a bunch of different code. I'll put all the code down in the comments of this video, if you're watching it on YouTube, so you can copy it if that's what you're interested in doing. But those bits of code will allow you to go and create a fill bar, with moving percentage text, and also a countdown timer, just like that, right here in Adobe After Effects. And yes, there you have it, ladies and gentlemen, indeed! A little loading bar, with the percentage text, countdown, or count up, in that case, as well as the minute and second countdown. Really, really cool stuff. I hope you enjoyed it. I hope you had a blast going through this tutorial. Learned, maybe, a thing or two, as well. If you do the Instagram thing, you can follow me over there on Instagram. At the very least, make sure you subscribe to this YouTube channel, so you never miss any tutorials in the past, present, or future. Am I missing anything? I don't think so. I think that's it. For everything we talked about here. All those little expressions, and variables, and operators, and functions, and man! We covered a lot, didn't we? For all that, and so much more, ladies and gentlemen, that's it! Get it? Got it? Good! Nathaniel Dodson, tutvid.com, I'll catch you in the next one!
Info
Channel: tutvid
Views: 69,069
Rating: undefined out of 5
Keywords: after effects, after effects tutorial, after effect CC, after effects tutorials, after effects countdown, after effects expressions, how to, after effects loading bar, loader, live countdown, countdown splash screen, splash screen after effects, after effects countdown tutorial, after effects timer tutorial, after effects linear, after effects variables, visual effects, time in after effects, tutvid, nathaniel dodson, AE, how to expressions, expressions
Id: jmRd1dmbTcI
Channel Id: undefined
Length: 23min 40sec (1420 seconds)
Published: Thu Jul 12 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.