Linking multiple keyframes to layer markers ?

Long story short: I’m trying to link multiple keyframes to layer markers. when someone wants to re-lengthen the animation all they have to do is drag the second layer marker and the animation lengthens accordingly.
does anyone know how to do that. ?

Apply this expression to all the properties/keyframes you want to be affected. Change “L” into the layer the expression is applied to:

L = thisComp.layer("Your Layer With The Keyframes");

if ((L.marker.numKeys > 0) && (numKeys > 1)){ 
   t1 = key(1).time; 
   t2 = L.marker.key(1).time; 
   val1 = valueAtTime(key(1).time); 
   val2 = valueAtTime(key(2).time); 
   linear(time,t1,t2,val1,val2);

} else { 
  value;
}

Thanks Motionvids

But This expression only works to connect the second keyframe to the marker, and it disables all keyframes after the second keyframe.

You have to manually connect each keyframe to the marker and define what is happening linearly in time. But it has it’s limitations. Here’s an expression based of a Dan Ebberts one that works if you have 4 keyframes.

This only works if keyframes 1 and 2 animate an object in and keyframes 3 and 4 animate the object out. Keyframes 2 and 3 have to be of the same value. You’ll also have to have one marker for the in animation and one for the out animation. Now you can drag each markers individually to change the in and outpoint of the animation on your layer.

L = thisLayer;
if ((L.marker.numKeys > 1 ) && (numKeys > 3)){
  sIn = key(2).time - key(1).time;
  sOut = key(4).time - key(3).time;
  eIn = L.marker.key(1).time;
  eOut = L.marker.key(2).time;
  if (time < L.marker.key(2).time)
    linear(time,eIn-sIn,eIn,key(1).value,key(2).value)
  else
    linear(time,eOut,eOut+sOut,key(3).value,key(4).value);
}else 
  value;

If you want to even have more keyframes and markers controlled I think it is better to experiment with “nearestKey()”.

Yes it works now for what I need it. ThankYou! Motionvids

How did you get it to work?

I’m also trying to create multiple markers& key frames to control various dates on a time remapped timeline.

It wasn’t as simple as going(I want more than 3 markers, this is just an example):
L = thisLayer;
if ((L.marker.numKeys > 0) && (numKeys > 1)){
t1 = L.marker.key(1).time;
t2 = L.marker.key(2).time;
t3 = L.marker.key(3).time;
v1 = valueAtTime(key(1).time);
v2 = valueAtTime(key(2).time);
v3 = valueAtTime(key(3).time);
ease(time,t1,t2,t3,v1,v2,v3)
}else{
value
}