FORUMS: list search recent posts

Time remap expression: jump to new point in clip and continue playing from

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dylan Champagne
Time remap expression: jump to new point in clip and continue playing from
on Jan 14, 2018 at 10:54:23 pm

I’m trying to use a time remap expression to get a clip to jump to a random frame and continue playing from that random frame. I want to be able to trigger this action with a keyframed switch (or value) on another layer so that every time the switch is “on” (which it would only be for one frame at any given time) the time remap expression grabs a random value to tell the clip to jump to and continue playing from.

I’m having a difficult time wrapping my head around how to do this because of the fact that After Effects runs the expression fresh on every frame, resetting any declared values.

I know there is a way to do it and it probably has to do with running a “for” or “while” loop but that’s as far as I’ve gotten.

Any help would be greatly appreciated.

Thanks so much.


Return to posts index

Dan Ebberts
Re: Time remap expression: jump to new point in clip and continue playing from
on Jan 15, 2018 at 12:55:47 am

How you set it up depends on the nature of your trigger. If every keyframe triggers a new random frame, your time remapping expression could look for the most recent previous keyframe (no looping necessary), use that keyframe's index as the random seed, set the seed, select a random start frame (within a range that ensures it won't get to the end of the clip), and use the time elapsed since the keyframe plus the time of the random start frame as the output of the expression. Pretty straightforward, but the exact code depends on how you have things set up.

Dan



Return to posts index

Dylan Champagne
Re: Time remap expression: jump to new point in clip and continue playing from
on Jan 15, 2018 at 1:30:17 am

Thanks a bunch. This is really helpful and makes sense in concept – I think. I'm unclear as how to "look for the most recent previous keyframe" and use its index or how to determine "the time elapsed since the keyframe" however.

Also, below is the original attempt at the expression for reference. I quickly realized that the entire approach was wrong (because "myTime" is not persistent) and that clearly I didn't know how to use "time" correctly.

var myTime;
if (thisComp.layer("bang").effect("output")("Slider") > 0) myTime = thisComp.layer("bang").effect("randomizer")("Slider") else myTime = time;
myTime;


Return to posts index


Dylan Champagne
Re: Time remap expression: jump to new point in clip and continue playing from
on Jan 17, 2018 at 5:09:05 pm

Thanks again Dan! I think I figure it out based on your instructions. Here's what I came up with:

p = thisComp.layer("BANG").transform.opacity;
d= 0;
indx = 0;
range = 6;
if (time >= p.nearestKey(time).time){
indx=p.nearestKey(time).index;
} else {indx = p.nearestKey(time).index-1}
d = Math.abs(time - p.key(indx).time);
seedRandom(indx, true);
output=Math.abs(random(range)+d);
if (output > range){ output -= range; }
output;

It's slightly different to implement than I'd imagined, but it works great. Feel free to suggest any tweaks etc.

Cheers... d


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]