13 Replies Latest reply on Aug 8, 2016 8:19 AM by Roei Tzoref

    Time clock/Countdown effect issue. Ahead of real time


      So I put a time icon in my song so it can have a little more visual appearance. Just one issue...It's a few seconds ahead of how long the song actually is. I put in the code

      amtOfDigits = 2;

      seconds = Math.round( time % 59 );

      minutes = Math.floor( time / 59 );

      function addLeadingZeroes( v ){

          for( i = 0; i < Math.abs( amtOfDigits - (v + "").length ); i++)

             v = "0" + v;

          return v;

      } addLeadingZeroes(minutes) + ":" + addLeadingZeroes(seconds)


      Notice the song is on 3 minutes but the time says 3:03


      time clock issue.png

        • 1. Re: Time clock/Countdown effect issue. Ahead of real time
          Mylenium Most Valuable Participant

          Well, 59 is not 29.97 nor is it 59.94, is it not? You math is crooked. Just fill in the correect values.



          • 2. Re: Time clock/Countdown effect issue. Ahead of real time
            Roei Tzoref Adobe Community Professional

            I find that the expression you provided not working as it should, no matter what number you put in there. after some research, I found the following expression that does the same thing and is much simpler:


            sec = Math.floor(time%60);

            min = Math.floor(time/60);


            {"0" + min +":0" + sec;}


            {"0" + min +":" + sec;}


            got it from here: After Effects: Tutorial | How to display time & create a countdown - YouTube

            • 3. Re: Time clock/Countdown effect issue. Ahead of real time
              Rick Gerard Adobe Community Professional & MVP

              One of the best approaches is to use Dan Ebberts Universal Timer from his Motion Script site. You have more control, can count up or down and can adjust the rate of the counter.


              If you are just counting up a very quick option and the one I would probably use is to use the Expression Language Menu from AE and just grab the time to timecode option from there and then must mask off the hours and frames:

              Screen Shot 2016-08-06 at 8.17.18 AM.png

              Showing mask but mask currently set to none.

              Screen Shot 2016-08-06 at 8.54.43 AM.png

              This is painless, quick and easy and suitable for any beginner. Just make sure you use a monospaced font so the numbers don't jump around. There is also a Timecode Effect under the Effects>Text but that does not give you the option to choose your font so it's kind of clunky.


              You can modify either of those expressions to subtract the in point of the layer so the timer will start from the in point or you can set a marker that will start the timer.


              But Wait, the numbers say 02:59;29 and the Timeline says 2;59;28. If you move the CTI so the Current time is 2;59;29 then the numbers read 3:00:00. Move forward one more frame and the CTI will read 3;00;02 and the numbers will read 3:00:01. What's going on.  


              Screen Shot 2016-08-06 at 8.39.38 AM.pngFor the time to display correctly as hours minutes and seconds when using NTSC based footage with fractional frame rates of 29.97 or any of the other fractional time rates you must set your comp to Drop Frame timecode.


              This is automatically assigned if you use any of the NTSC based presets. No frames are dropped, only frame numbers because the frames cannot be divided into even numbers. This Drop Frame way of counting frames, again not dropping frames but counting frames, happened when color television was introduced and they had to add a couple more scan lines to the TV signal to send along color burst information. Drop frame timecode is indicated in the timeline by the use of a ; instead of a : to separate the hours, minutes, seconds and frames.


              That explains the CTI display, what about the numbers display when you use the expression for time to timecode? Why does it appear to be one frame behind? Because at 1 minute into the count DropFrame timecode starts dropping frame numbers and the Time to Timecode expression from the Expression Language menu takes this into account because the dreamt time base is 30 not 29.97. There is an option for Time  to NTSC timecode that will match up the CTI and the number display.


              One last point, The numbers time display is one frame behind the actual time it takes the layer to play because the CTI stops at the head of the last frame. If your video is 3 minutes long then it will take exactly 3 minutes to playback even though the last frame in the video has a frame number one frame less than the length of the video. If you want your time display to actually show 3:00 you'll have to extend the layer by 1 frame to give the number time to display.


              Ok, a second last point... Your expression will work properly if you change the 59 to 59.94 because you are using rounding to jump up one frame and 59.94 is the proper divisor for time when you are using drop frame timecode.

              • 4. Re: Time clock/Countdown effect issue. Ahead of real time
                Roei Tzoref Adobe Community Professional

                Thank you Rick for laying it down. trying to be picky here so after runnings some more tests it seems that both expressions (Op's and the one I copied) cannot represent the actual time code. I have downloaded a music with a video playing at 29.97 - this is the video: The Cars - Magic (HQ).mp4 - Google Drive


                when I drag it to a composition it seems the only way to make the timecode work at all frames is to use like you said - the ntsc expression:

                timeToNTSCTimecode(t = time + thisComp.displayStartTime, ntscDropFrame = false, isDuration = false)


                would you agree?


                nothing else sticks. not Op's expression (with 59.94 or not), not Dan's expresiion, and not the one I contributed here. drop frame or no.

                notice the difference between what's on screen and the Timeline actual timecode:


                Op's expression set to 59.94 ND Frame

                Op's expression set to 59.94 D Frame

                Dan's Expression ND Frame

                Dan's Expression D Frame

                I also tried another video at 23.97 and still the timecode won't stick, but only with the ntsc expression.


                Dan's expression


                what do you make of this?

                • 5. Re: Time clock/Countdown effect issue. Ahead of real time
                  Rick Gerard Adobe Community Professional & MVP

                  First, Adding a video to the timeline has nothing to do with the time display at all. If you have a video of a known length, say 3 minutes, and it is properly interpreted you can drop it in any comp, even one that is 10 fps, and it will still playback at the right speed. There was no need for you to add a video to your test. All you need be concerned with in this problem is the display of the comp time and frame number as it relates to true time. Let me talk about this example set of comps:

                  Screen Shot 2016-08-07 at 3.20.38 AM.png

                  First let's talk about how the CTI works in conjunction with an entered time. If your comp is set to 29.97 (or any fractional time base) and you type 3;00;00 and the comp is set to drop frame timecode as it should be, AE will round down the time you entered and position the CTI on the frame that is nearest to 3 seconds giving time for the last frame to playback. This means that when your comp is set to 29.97 the nearest frame to 3 seconds is 2;29;28 because frame 2;29;29 would actually last approximately .02 seconds longer than 3 seconds. If you submit a program or commercial to a broadcaster that is 1 frame longer or even .02 seconds longer than it should be it may be rejected. When the frame rate is 24 or 23.976 drop frame time display is not an option. It only works with 29.97 or 59.94. If you are not using Drop Frame timecode display the rounding is disabled so you end up at 3:00:00. That's how it works with all NLE's and all compositing apps because that's the standard as written by SMPTE. This math is correct and has been industry standard forever. When you have drop-frame timecode selected and you zoom into the timeline all the way the 'dropped' frame number is highlighted. It's always going to be after the nearest whole second and always be 02 in a 29.97 comp.

                  Screen Shot 2016-08-07 at 3.35.18 AM.png

                  NON DROP frame timecode never gives the correct time after the first minute. If you use non drop frame timecode display and your timeline is longer than 1 minute the time display and true running time of your comp will always be incorrect. There is no practical reason at all for using non-drop frame timecode. The need for non-drop frame timecode went away with the demise editing video tape with magnetic powder and a razor blade and digital control of tape decks. It was never used for timing a program because the running time in hours, minutes and seconds after 1 minute is always wrong.


                  The default time base for Time to Time code is 30 fps. If you want that to give you frame numbers at different frame rates you need to change that. Set it to 24 for your 24 fps comp. This method will not give you the correct frame number in a 23.976 comp because those comps are not set to drop-frame timecode and the method assumes that they are whole frame numbers. It's a bug in the method. You can see that in the 23.976 comp on the right. The frame count at three seconds is off by five.


                  Now let's talk about the NTSC default expression language method. The default the NTSC method is non drop frame. You have to change that to drop frame by changing the nonDropFrame to true to display the correct time for NTSC (29.97 or 59.94) drop frame comp.

                  Screen Shot 2016-08-07 at 2.55.04 AM.png

                  This method will display the correct time and frame number plus one because it does not round down. The fractional frame rates like 23.976 will be off in the frame count because there has been no provision in the method for 23.976 fps which are not interpreted as drop frame for the purposes of the method. Currently there is no automatic precise way to get a drop frame frame count in a comp that is 23.976 fps. If you apply the NTSC method set to drop frame then you won't get the correct frame count for the 23.976 comp, you'll get the correct frame count if the comp was 29.96 drop frame. You can get the proper frame count for any frame rate comp by combining 1/this.Comp.frameDuration with some other math but I won't go into that now. Let's just say that it's a modification of Dan's universal timer that changes milliseconds to frames.


                  Dan's expression will always give you the correct running time of the composition including the last frame no matter what the frame rate of the comp because it works strictly on time. The differences in the time display for the tree comps using Dan's expression is the difference in the length of time it will take the last frame to play. As long as you set the speed to 1 and the starting time to 0 Dan's expression will always give you the correct running time of the comp. In your example showing a difference in the timeline and the displayed time from Dan's expression you are not taking into account the duration of the last frame. Dan's method is correct because it always displays the current time of the composition including the time it takes to playback the last frame.


                  Last example. I originally wrote that you could correct seanm987654's expression by changing 59 to 59.94 I was not correct. His expression just doesn't work. It appears to work when you set the CTI to 3;00;00 but if you back down the count goes from 3:00 to 3:60 then on down so the true time is never displayed. With a little head scratching I could make the idea work but it's just not worth it. I should have caught that problem but I didn't take the time to really think about the math.


                  The original question was how to fix the time display in a 29.97 comp - That's been answered.

                  • 6. Re: Time clock/Countdown effect issue. Ahead of real time
                    Roei Tzoref Adobe Community Professional

                    thank you Rick. you are an encyclopedia for this software and as always - appreciate you are taking the time. I admit the technicalities of drop frame vs non drop is beyond me. part of it's is because my poor math skills, and the other is because almost all of my work is on whole frame rates. I work in a PAL country so it's either that for broadcast or HD square. I am not experienced by practice with this issue. I realize the CTI is not a "clock on the wall" and that's what's so confusing.   you wrote valuable information here but I am sorry to say that I can get maybe only half of it. maybe after a while and with more practice I will wrap my head around it and fully get it.

                    There was no need for you to add a video to your test.

                    got it. thank you

                    • 7. Re: Time clock/Countdown effect issue. Ahead of real time
                      seanm987654 Level 1

                      Ok that definitely helped the real time! Thank you. Now 1 more thing...Now the time goes up to :60 seconds and then goes onto the next minute. So it'll will be at 3:60, then it will hit 4:00. I want it so be the :59 seconds then hit the next minute. Any idea how to do this?

                      • 8. Re: Time clock/Countdown effect issue. Ahead of real time
                        Roei Tzoref Adobe Community Professional

                        seanm987654 you can see that this thread went way way beyond your question but our top specialist here wrote that your expression does not work. you can try this timer by the master genius Dan Ebberts that is claimed to be perfect: Dan Ebberts's Expressioneering Design Guide

                        • 9. Re: Time clock/Countdown effect issue. Ahead of real time
                          seanm987654 Level 1

                          Hmm I just tried that and got these results. Any reason why? Roei Tzoreftime clock issue.png

                          • 10. Re: Time clock/Countdown effect issue. Ahead of real time
                            Roei Tzoref Adobe Community Professional

                            Yes. you need to set the speed (rate) to 1 and the clockstart to 0. it should be written like this:


                            rate = 1;

                            clockStart = 0;


                            function padZero(n){

                              if (n < 10) return "0" + n else return "" + n



                            clockTime = clockStart + rate*(time - inPoint);


                            if (clockTime < 0){

                              sign = "-";

                              clockTime = -clockTime;


                              sign = "";



                            t = Math.floor(clockTime);

                            hr = Math.floor(t/3600);

                            min = Math.floor((t%3600)/60);

                            sec = Math.floor(t%60);

                            ms = clockTime.toFixed(3).substr(-3);

                            sign + padZero(hr) + ":" + padZero(min) + ":" + padZero(sec)

                            • 11. Re: Time clock/Countdown effect issue. Ahead of real time
                              Rick Gerard Adobe Community Professional & MVP

                              Set the rate to 1 and the start time to 0 (first two lines).


                              At the bottom of the expression you will see language that displays milliseconds. Delete that.


                              If you had read Dan's post who would understand that his example is counting down to zero at two times normal speed.

                              1 person found this helpful
                              • 12. Re: Time clock/Countdown effect issue. Ahead of real time
                                seanm987654 Level 1

                                You guys are the best!! Thank you so much! I got it Rick Gerard Roei Tzoref

                                • 13. Re: Time clock/Countdown effect issue. Ahead of real time
                                  Roei Tzoref Adobe Community Professional

                                  you're welcome! glad to help. thanks for updating the thread for the correct answer. Rick doesn't mind the points, they are running out of screen space for his anyways