Page 1 of 1

Script to compress motion using marker sets

Posted: May 26th, 2008, 7:59 am
by pdeb
Hi everyone, thanks for your continued support of the AE community!

I originally posted this under the expressions discussions, but as I look under the hood a little more it seems this is more of a script-based challenge.

Inspired by Lloyd Alvarez's recent expressions, I'm trying to create an interactive way to compress position based on sets of markers. Here's the process I'm trying to work through, though not much success with my basic knowledge of iterative loops:

1. start with 2 linear-interpolation position keyframes to indicate start and end position of the layer
2. somewhere between these keyframes, add 4 markers - marker.key(1) and marker.key(4) indicate the positional values where the compression of the motion will take place; marker.key(2).time indicates the new time of marker.key(1).value; marker.key(3).time indicates the new time of marker.key(4).value (see image attached)
3. run script to remap positions values, and add easing between marker.key(2) and marker.key(3) to create the overall effect of constant velocity -> speed ramp -> constant velocity
4. if there are multiple compressions within the start and end keyframes, perform an iterative check for sets of 4 markers [1,2,3,4] and [5,6,7,8] and remap values accordingly, keeping motion linear outside these sets of 4 markers.

I know this can be done by precomposing and time-remapping, I'd prefer to keep it on one layer in one comp and have it done with markers.

thanks for your help, Peter
markers_ramp.jpg
markers_ramp.jpg (84.87 KiB) Viewed 19461 times

Re: Script to compress motion using marker sets

Posted: May 26th, 2008, 10:12 am
by Dan Ebberts
I think it's better as an expression. ;-)

It needs two keyrames and 4 markers to do anything.

Code: Select all

if (marker.numKeys >= 4 && numKeys >= 2){
  inTime = key(1).time;
  outTime = key(2).time;
  t1 = marker.key(1).time;
  t2 = marker.key(2).time;
  t3 = marker.key(3).time;
  t4 = marker.key(4).time;

  if (time < t2){
    t = linear(time,inTime,t2,inTime,t1);
  }else if (time <= t3){
    t = ease(time,t2,t3,t1,t4);
  }else{
    t = linear(time,t3,outTime,t4,outTime);
  }
  valueAtTime(t)
}else{
  value
}

Dan

Re: Script to compress motion using marker sets

Posted: May 26th, 2008, 11:50 am
by pdeb
Thanks as always, Dan! I'm going to try to vary the easing based on Ian Haugh's ease and wizz

P

Re: Script to compress motion using marker sets

Posted: October 23rd, 2018, 9:57 am
by reubenlara
Be sure to check out Marker Remap http://aescripts.com/marker-remap which builds an After Effects panel around split layer markers and has the additional bonus of a robust marker management panel. Gives AE CC 2019's new Responsive Design features a run for it's money!