Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomly hold and skip frames?

  • Randomly hold and skip frames?

    Posted by Noel Powell on March 27, 2012 at 7:46 pm

    Hi AE gurus –

    This seems like such a basic effect but I’m stumped. I’m going for a glitchy digital video effect where the video randomly freezes, then skips ahead to resume playing. I can easily do this by using hold keyframes in the Time Remapping effect, but I would like to be able to do it with an expression because of the amount of video I have to work with.

    I made a duplicate footage layer and applied a posterize time effect, then I added an expression to the opacity to randomly turn the layer on and off, revealing the unaffected footage layer underneath, but this didn’t quite accomplish what it wanted. It needs to play, then freeze, then skip ahead to the normal time, and do this repeatedly and randomly.

    Thanks in advance.

    Noel Powell replied 14 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 27, 2012 at 8:49 pm

    Something like this time remapping expression maybe:


    if (time >= 0){
    minPlay = .75;
    maxPlay = 1.5;
    minFreeze = .2;
    maxFreeze = .7;

    t0 = 0;
    seedRandom(index,true);
    while (t0 <= time){
    play = random(minPlay,maxPlay);
    freeze = random(minFreeze,maxFreeze);
    t = time - t0;
    t0 += play + freeze;
    }

    if (t > play) t0 - freeze else value
    }else
    value

    Dan

  • Noel Powell

    March 27, 2012 at 9:22 pm

    Works perfectly! It even adds a sort of glitch sound to the audio which really adds to the effect.

    Thank you!!

  • Julien Tourigny-Gagnon

    February 19, 2021 at 2:41 am

    Hi! I’d like to be able to understand this expression a bit better. I think that i lack knowledge about the way After Effects evaluate expressions to be able to fully understand how this algorithm works.

    Question 1 : How does AE evaluates the random functions in this case? To my knowledge, since seedRandom is used with timelesss = true, the values returned by the random() functions should always be the same.

    Question 2 : Is t0 kept in memory somehow? From what i understand, t0 will be reset to 0 every frame before going through the while{} loop. (and will always end up being a bigger value than time at the end of the expression evaluation)

    Question 3 : Now if i understand the rest of the expression, this will always push t0 ahead of the current time and i don’t understand how the final condition could be met (t > play) since t is most liekly always going to be a negative value.

    Thanks to anyone who can help me understand this better. I really don’t like to use expressions if i don’t know how they work.

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