Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions simple way to control a precomps duration with a marker perhaps ?

  • simple way to control a precomps duration with a marker perhaps ?

    Posted by Adam Greenberg on February 10, 2023 at 9:09 pm

    Sorry for the strange title. I will explain the issue.

    So I have a composition that has elements animating in and then animating out, so the total duration is 10 seconds.

    The toolkit I am making for the editors would need to have an easy way to control this duration but not retiming the beginning or the ending.

    Currently, there are 2 work arounds.

    1. The editor splits the layer and shortens the second layer manually by dragging the layer earlier and trimming off the overlapping part.

    2. The smarter way is a time remap with 4 keyframes, and they move the last 2 key frames earlier or later.

    I have seen a video where you can attach these keyframes to a slider and manually punch in a duration, but I am wondering if there is more visual way to do this, like moving a marker, or perhaps trimming off the end and there is some dynamic link between the the length of the layer and the actual animation inside it.

    If anyone has any thought or ideas, that would be great. ( Keeping in mind I would like to avoid punching in a value into a slider. )

    Thanks everyone

    Adam Greenberg replied 3 years, 2 months ago 2 Members · 5 Replies
  • 5 Replies
  • Andrei Popa

    February 12, 2023 at 6:31 pm

    Well, since you are building this toolkit, I think you have the data for this expression. You need the duration of the in-out animation.

    Then apply this to the time-remap property:

    inDur = 1;
    outDur = 1;
    myMarker = marker.key(1);
    if (time > myMarker.time - outDur) {
    linear(
    time,
    myMarker.time - outDur,
    myMarker.time,
    key(2).time - inPoint - outDur,
    key(2).time - inPoint
    );
    } else {
    linear(time, inPoint, inPoint + inDur, 0, inDur);
    }

    However, I would do it different. You can use the following expression, and just cut the layer where you want it to end. And the animation will follow the out-point of the layer:

    inDur = 1;
    outDur = 1;
    if (time > outPoint - outDur) {
    linear(
    time,
    outPoint - outDur,
    outPoint,
    key(2).time - inPoint - outDur,
    key(2).time - inPoint
    );
    } else {
    linear(time, inPoint, inPoint + inDur, 0, inDur);
    }
  • Adam Greenberg

    February 13, 2023 at 1:58 pm

    Excellent Andrei !!!! Thanks so much, I like this way, no need to drag a marker at all.

    Very dynamic.

    Well Done !!!

  • Adam Greenberg

    February 16, 2023 at 6:46 pm

    Andrei, a quick follow up question.

    Is there a way to write this so that we could technically trim the beginning of the layer earlier or later as well ? if you try to do it now ( I tried just to understand the math ), it actually seems to keep the proper in animation, but we lose the integrity of the out animation.

    It’s not necessary for my purposes, but I couldn’t help asking just to know if it’s possible.

    Thanks again

  • Adam Greenberg

    February 23, 2023 at 5:09 pm

    I think we would need to get rid of the key(2).time part of the expression, but I am not sure how to tell after effects to look at the inpoint, keep the induration, then i guess freeze at that time, and then freeze until the outpoint – the outduration

    so for example of we had a 7 second precomp and it had animation inside from 0 to 1 second and animation from 6 to 7 seconds. and then we applied a time remap and the expression, and dragged the layer 1 second later and the out 1 second earlier ( giving us a 5 second duration ) the expression would apply the in animation to the first second from wherever this layer starts, and then backtime the last second of animation from 1 second before the outpoint of this precomp. so something like time, inpoint, inpoint + indur, 0, outpoint – inpoint – outdur, outdur.

    I dont even think we need an if else statement other than to accept the fact that if in this case the layers duration was less than 2 seconds, it would not work, but that would be fine as that would be too short anyways, I guess for arguments sake we can add and if else statement that would just speed up the whole thing in the case where indur+outdur is greater than outpoint-inpoint.

    does this logic work ?

  • Adam Greenberg

    February 23, 2023 at 6:49 pm

    I got it, thanks to searching in here for other time related expressions, and trial and error, and realizing we needed to tell the layer what the original duration was, otherwise how would after effects know where to put the out animation. I hope others find this helpful.

    And thanks so much to all of you who posted in the past when i was doing the searches;

    inDur = 1; // replace 1 with the duration of your in animation, in seconds, or divide frames by framerate

    outDur = 1; // replace 1 with the duration of your out animation, in seconds, or divide frames by framerate

    originalDuration = thisLayer.source.duration;

    if (time <= inPoint + inDur) {

    linear(time, inPoint, inPoint + inDur, 0, inDur);

    } else if (time >= outPoint – outDur) {

    linear(time, outPoint – outDur, outPoint, originalDuration – outDur, originalDuration);

    } else {

    inDur;

    }

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