Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control time remapping via slider

  • Control time remapping via slider

    Posted by Mike Park on February 21, 2009 at 10:23 pm

    I am attempting to control the clip playback velocity through using a slider control. Basically, I want to have the clip play normal speed when the slider is set to a value, but then be able to alter time remapping by keyframing a slider so that the video plays faster based on the keyframed slider. Similar to the recent tutorial by Aharon, using sound keys, but with a slider. The problem I am having is that I need to accumulate values in the slider to add to the time remapping value. I know it is probably very simple using java but, have looked around and somewhat stuck. I know you guys will have the answer and thank you in advance for your help.

    Filip Vandueren replied 17 years, 5 months ago 2 Members · 4 Replies
  • 4 Replies
  • Filip Vandueren

    February 21, 2009 at 10:58 pm

    Something like this should work:


    tr=0; // the start-value for time-remapping if not 0

    t=0;
    fd=thisComp.frameDuration;

    while (time>t && time>=inPoint) {
    sp=thisComp.layer("Null 1").effect("speed")("Slider").valueAtTime(t);
    tr+=sp*fd;
    t+=fd;
    }

    tr-inPoint;

    Change the “Null” and “effect-slider” name to your needs. Or pickwhip, but be sure to add the ‘valueAtTime(t);” after pickwhipping.

    This will start counting from the layer’s inpoint.

    I did a few tests and it looks to work OK.

  • Mike Park

    February 22, 2009 at 12:35 am

    Thanks Filip,

    worked like a dream. I am trying to understand why though. The only thing I don’t follow is what the operator “+=” does. I have had some computer programming classes in college, but I learned Fortran 77. Before I get any old fart jokes, I am only 31. I guess the dinosaurs they had teaching the classes decided to stick with what they knew. I have also coded (a very long time ago) in basic, but that was almost 15 years ago in high school.

    Thanks again for your time and response

  • Filip Vandueren

    February 22, 2009 at 12:58 am

    Hey Mike

    in most modern languages a+=3 is shorthand for a=a+3

    also a-=3, a*=3, a/=3

    and also a++ for a=a+1 and a– for a=a-1
    or ++a and –a, which behave subtly different.

    for example:


    a=2;
    dub(++a);

    function dub (a) {
    return a*2;
    }

    this returns 6 (2+1)*2, but:


    a=2;
    dub(a++);

    function dub (a) {
    return a*2;
    }

    this returns 4!
    Because “a” is sent to the function dub, and only AFTER any other use “a” could have in this statement, it is then increased. Good to know if a ++ line is the last thing in your expression, because returning the value comes before increasing it

    so don’t use

    a=1; a++;

    if you want 2 as result.

    use:

    a=1; ++a;

    or:
    a=1; a++; a;

  • Filip Vandueren

    February 22, 2009 at 1:30 pm

    Beyond operator semantics though:

    you have to understand that after effects expressions don’t work as many people expect them to:
    you can’t just say, remember what “tr” was last frame, just add the “speed-slider”-value to that, and we’re done.

    That’s why there’s the while loop, that recalculates the values for every frame that came before the current frame, and keeps a running total with the “tr+=…” statement.

    The fd (frameduration) is used because when speed=1, the timeremapping should be increased by .04 every frame (1/25fps for PAL) to gain 1 in 1 second.

    You’ll see this technique used in quite a lot of expressions where time is afactor.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy