Skip to main content
Participant
March 2, 2024
Question

Automatically adjusting the length of layers and keyframes based on changing the length of a precomp

  • March 2, 2024
  • 1 reply
  • 562 views

hi there! i'd like to ask if anybody has a script/expression I can use to make keyframes adjust depending on the timeline-length of a layer? meaning if I increase the out-point of a layer by two seconds, the values of "key(numKeys)" and "key(numKeys - 1) "will also only be applied to the property two seconds later? this would tie to the question if its possible to have a layer adjust its length based on the precomposition - meaning if a layer is within a precomposition and i adjust the duration of the precomposition, the layer would also adjust its length and due to a new out-point being available, the "transmission" of values from the keyframes to the property would also proportionally happen earlier or later appreciate any help:)

This one is one i've found in another forum post, but it doesnt seem to work for me - i'd apply the script to a layer within a precomposition to the "scale" property, having two keyframes, one at exactly the outpoint, and one one second before the outpoint. the keyframe has a custom easing curve having used the graph editor.

 

 

ip = thisComp.layer("ITEM.pdf").inPoint;
op = thisComp.layer("ITEM.pdf").outPoint;
d = key(numKeys).time - key(numKeys-1).time;
lengthDiff = op - ip - thisComp.layer("ITEM.pdf").source.duration;
if (time > (ip - d)){
    t = key(numKeys-1).time + (time - (ip - d)) + lengthDiff;
}else{
    t = Math.min(time,key(numKeys-1).time);
}
valueAtTime(t);

 

 

 

This topic has been closed for replies.

1 reply

Mathias Moehl
Community Expert
Community Expert
March 3, 2024

Maybe you want to use responsive design time?

 

My (paid) tool Automation Blocks for Ae also has a feature to insert frames into the active comp at the current time, which changes the duration of precomps and shifts layers and keyframes as needed.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects