Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Time remap expression and slider

  • Time remap expression and slider

  • Adam Greenberg

    March 18, 2016 at 7:48 pm

    Hi, I am making a template with a finished composition that currently is exactly 5 seconds and 10 frames long ( so 10;00;00;00 to 10;00;05;09 to be exact )

    project is 29.97 fps

    I have this composition in another composition with time remapping enabled, and here is what I am trying to do.

    I need this composition to be flexible in duration up to 10:10 ( which is having an out at 10;00;10;09 to be exact )

    SO the duration could be anywhere from 5:11 to 10:09 and anything inbetween

    But there are 2 conditions and 1 complicated math conversion.

    The first condition is that the first 26 frames ( so 10;00;00;00 to 10;00;00;25 ) cannot be remapped, so the expression needs this animation to stay the same regardless of the slider number entered. The second condition is the last 2 seconds ALSO needs to stay the same ( from 10;00;03;12 to 10;00;05;09 ) – so actually its just a bit less than 2 seconds.

    The time remap expression will alter the speed from 10;00;00;25 to 10:00:03:11 ) and that is exactly what I want.

    The other part of the math I am having a hell of a time with; is that this slider will have a decimal point. So let us say that the user enters 7.17 as the input value into the slider.

    I want this to represent 7 seconds and 17 frames which logically would give me a time code of 10;00;07;16 ) because the comp starts at 10;00;00;00;00

    On paper I have solved the math on this but I cannot seem to write the code. My knowledge of writing expressions from scratch is simply not good enough.

    I figured the math part would be
    the fixed number of the slider without the decimals multiplied by 30 + the difference between the whole number and the number without the decimals multiplied by 100

    that would give me 7 times 30 which is 210
    + (7.17-7) which is .17
    multiplied by 100 which is 17 plus the original 210
    =

    227 frames

    Then in the expression for the time remap to work correctly this number needs to get converted to timecode.

    I hope I have given all relevant information and any help would be much appreciated.

    Thanks

  • Miguel de Mendoza

    March 22, 2016 at 10:26 am

    Is a little confusing what you are trying to achieve for me, but I can tell you that you cant’t change the duration of any composition by expression, for that you need to use a script.

    [Adam Greenberg] “The time remap expression will alter the speed from 10;00;00;25 to 10:00:03:11 ) and that is exactly what I want.

    The other part of the math I am having a hell of a time with; is that this slider will have a decimal point. So let us say that the user enters 7.17 as the input value into the slider.

    I want this to represent 7 seconds and 17 frames which logically would give me a time code of 10;00;07;16 ) because the comp starts at 10;00;00;00;00”

    A simplest way to achieve that is to converting the input value to string and then split the string:

    sliderVal = thisComp.layer("sliderLayer").effect("Slider Control")("Slider").value;
    stringVal = sliderVal.toString();
    timeFrames = stringVal.split(".");

    At that point you only need to map the frame value (timeFrames[1]) to your framerate.

  • Adam Greenberg

    April 1, 2016 at 7:22 pm

    Well I do not need to change the duration of this main output composition. The composition is set to lets say 10 seconds for example, but the precomp ( which is 5:10 ) in this comp has time remap enabled.

    For now, manually I have 4 key frames and the person who edits this composition to the desired duration must move the 3rd and 4th keyframe together to the time they desire, for example 7 seconds and 10 frames.

    But I know I can achieve this with an expression. manually moving keyframes leaves room for human error.

    The best way to visualize this, is think if a logo that animates in a certain way in 25 frames, slowly zooms in until it animates out at the end in 57 frames.

    Well in order to make this logo shorter or longer, you would need 4 keyframes in a remap.

    The first 2 remain fixed in time so that you do not change the speed in which it animates it. the 3rd and fourth need to be moved together in order to respect the speed of the animation out.

    Of coarse the speed of the middle is what changes.

    I know i can can create 4 variables so that variable 1 and 2 never change. variable 4 would be the main formula I am looking for which also converts my slider to frames, then variable 3 would be variable 4 minus 57 frames. Then the template would be driven by this main expression linked to the slider.

  • Dan Ebberts

    April 1, 2016 at 8:56 pm

    assuming your slider is on a layer named “controls”, it might look like this:


    if (numKeys == 4){
    s = thisComp.layer("controls").effect("Slider Control")("Slider");
    d = key(4).time - key(3).time;
    if (time < key(2).time){
    value;
    }else if (time < s-d){
    linear(time,key(2).time,s-d,key(2).value,key(3).value);
    }else{
    linear(time,s-d,s,key(3).value,key(4).value);
    }
    }else
    value

    Dan

  • Adam Greenberg

    April 4, 2016 at 1:14 pm

    Thanks Dan, I think you are on to something, however, it is not giving me the expected result. And I believe that is due to my explanation.

    the 3rd keyframe should always be the 4th keyframe minus a fixed value.
    this fixed value is 57 frames.

    so that the animation between those 2 keyframes never changes.

    For example, right now, if I enter 6 in your slider,

    the 4th keyframe becomes 00;00;04:18
    and the 3rd becomes 00;00;04:01

    What should happen is the 4th should be 00;00;06;00

    and the third should be ( 6:00 – 57 frames ) – so 00;00;04:03

    if i add 8.22 in the slider

    I would like to see the following

    keyframe 4 = 00;00;08;22
    keyframe 3 = 00;00;06;25

    if someone enters 3.15 in the slider

    keyframe 4 should be 00;00;03;15
    keyframe 3 should be 00;00;01;18

    FYI – the original 4th key frame is at 00;00;05:09
    and the 3rd is at 00;00;03;12

    In all instances,
    key frame 1 should be 00;00;00;01
    keyframe 2 should be 00;00;00;25

    This is a 29.97 comp by the way.

    Thank you.

  • Dan Ebberts

    April 4, 2016 at 4:58 pm

    Like this then:


    if (numKeys == 4){
    s = thisComp.layer("controls").effect("Slider Control")("Slider");
    d = key(4).value - key(3).value;
    if (time < key(2).time){
    value;
    }else if (time < key(3).time){
    linear(time,key(2).time,key(3).time,key(2).value,s);
    }else{
    linear(time,key(3).time,key(4).time,s,s+d);
    }
    }else
    value

    Dan

  • Adam Greenberg

    April 26, 2016 at 7:16 pm

    Hi Dan, I have been studying the expression to understand why its not behaving as expected. But to keep things short, when I increase the slider, the key frame value ( of keyframe 3 and 4 ) goes down. For anyone who is interested in this advanced control I am looking for, here is something very very close I found on the web, but I can not adapt it to my needs.
    Enjoy ( youtube link and expression below )

    For this template I had no choice but to accept the fact that I can not achieve what I want, but I know its possible. Thanks again for your help. As my template is, there is only one step more in my procedure, so no big deal.

    https://www.youtube.com/watch?v=sWw4E_gLXlI

    var fps = 1/ thisComp.frameDuration;

    //sliders values
    var lt = comp(“controls”).layer(“controls”).effect(“logo-total”)(1)*fps;
    var li = comp(“controls”).layer(“controls”).effect(“logo-in”)(1)*fps;
    var lo = comp(“controls”).layer(“controls”).effect(“logo-out”)(1)*fps;

    var m1 = 0;
    var m2 = framesToTime(li);
    var m3 = framesToTime(lt – lo);
    var m4 = framesToTime(lt);

    //keyframes in your original composition
    //change these numbers depending on the key moments of your composition
    var k1 = 0;
    var k2 = framesToTime(50);
    var k3 = framesToTime (87);
    var k4 = framesToTime(112);

    if (time < m2) {
    linear (time, m1, m2, k1, k2);
    } else if (time < m3) {
    linear (time, m2, m3, k2, k2);
    } else {
    linear (time, m3, m4, k3, k4);
    }

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

Viewing 1 - 7 of 7 posts

Log in to reply.

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