ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trying to create a counter layer with automatically adjusting inPoint and outPoint

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rens Jansen
Trying to create a counter layer with automatically adjusting inPoint and outPoint
on Aug 26, 2018 at 9:42:58 pm

Hello everyone! I'm new to this forum and I must admit I'm not that experienced with Adobe yet. Now then, on to my question..

I've created a video template that displays some information about a music track, Among its features is a time counter, this time counter simply displays the remaining duration of the music track and counts down to zero. To get this time counter to work I had to put the following code into its source text:


countspeed = 1;
clockStart = 0;

function times(n){
if (n < 10) return "0" + n else return "" + n
}

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

if (clockTime < 0){
minus = "-";
clockTime = -clockTime;
}else{
minus = "";
}

t = Math.floor(clockTime);
h = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(3).substr(-3);
times(min) + ":" + times(sec)


Untill now I had to manually adjust the time counters layer outPoint to correspond with the outPoint of a layer containing the music file, this would ensure that the time counter displayed the right duration for the countdown. I figured there must be a way to automize this, but I couldn't find a function for this in Adobe After Effects itself. However, I thought this would be something that could be achieved through script as well. Online I found the following code:


var myComp = app.project.item(4);
var myLayer;
var myNextlayer;

for(i=5;i=3;i--) {
myLayer = myComp.layer(i);
myNextlayer = myComp.layer(i-1);
var x = myLayer.inPoint;
x = x;
myNextlayer.inPoint = x;
};


I've been unable to combine the first code with this second code in a working manor, all I ever got was errors. I was hoping the experts around here could offer me a helping hand in achieving my goal. Also, I'll gladly provide more information!

Thanks in advance and kind regards,

Rens


Return to posts index

Dan Ebberts
Re: Trying to create a counter layer with automatically adjusting inPoint and outPoint
on Aug 26, 2018 at 11:50:04 pm

Try this:


function times(n){
return (n < 10 ? "0": "") + n;
}
L = thisComp.layer("audio");
dur = L.outPoint - L.inPoint;
t = Math.max(dur - Math.max(time - L.inPoint,0),0);
t = Math.floor(t);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
times(min) + ":" + times(sec)



Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]