Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to loop but trim last couple of frames?

  • Expression to loop but trim last couple of frames?

    Posted by Xavier Paredes on October 25, 2018 at 4:03 pm

    I have about 200+ videos. Each needs to be looped X amount of times. I have an expression (see below) that allows me to do this and it works just fine for [most] videos. Unfortunately, some videos have a couple of frames of black at the tail end so when I loop them using the expression, those black frames get included therefore they flash every time the loop happens.

    The only way I know to prevent this is to trim the black from the videos in FCPX and re-export them.

    I’m wondering if there’s a better expression so I don’t have to trim and re-export in FCP.

    I’m on a tight deadline :/

    Thanks for any help!

    nLoops = 100;
    if (numKeys > 1){
    loopDur = key(numKeys).time - key(1).time;
    n = Math.floor((time - key(1).time)/loopDur);
    if (n < nLoops){
    t = (time - key(1).time)%loopDur;
    valueAtTime(key(1).time + t);
    }else{
    valueAtTime(key(numKeys).time);
    }
    }else
    value;

    Xavier

    Xavier Paredes replied 7 years, 6 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    October 25, 2018 at 4:18 pm

    This is a time remapping expression, yes? One thing you could do would be to move the Current Time Indicator to the last good frame, and set a keyframe there, and then delete the last keyframe. Give that a try.

    Dan

  • Xavier Paredes

    October 25, 2018 at 5:55 pm

    Hi Dan,

    Your solution works! Interesting though, It’s basically the same thing I was doing. The only difference is that I have to move the keyframe [before] I extend the layer. If I extend the layer first and then I move the keyframe, the black frames will show. I don’t understand why but Oh well! ¯\_(ツ)_/¯.

    Thanks!.

    Xavier

  • Dan Ebberts

    October 25, 2018 at 5:58 pm

    You’re not actually moving the keyframe, right? You should be creating a new one a couple frames earlier than the last one then deleting the last one.

    Dan

  • Xavier Paredes

    October 26, 2018 at 2:59 pm

    Uhhhh… I actually was just moving the last keyframe and it works (so long as I do this first before I extend the layer)…

    But I also tried (as you suggested) creating a new keyframe on the last good picture frame of the videos and this works as well.

    I’m going to stick to your most recent advice.

    Thanks so much!

    Xavier

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