extendscriptafter-effects

shift keyframe time in extendscript


I would like to shift the time of some keyframes on a layer to be x seconds/frames later. In the Extendsript documentation there is a function for setting a keyframe's value, but none I could find for setting a keyframe's time.

I do not want to modify the layer's in/out points and this will need to be able to operate on selected keys only, so just shifting the layer around doesn't quite pan out as a workaround.


Solution

  • There is no actual keyframe object in the After Effects API. There are just properties, and a bunch of methods to get information about the keyframes of those properties. For a program that is all about the keyframes this seems … kinda like the sorta thing Adobe would do.

    So what you have to do is copy all the attributes of the key you want to move, like the temporal ease, spatial tangents and so on, then create a new key with those properties, then delete the original key (which can also be a gotcha, because if you've inserted the new key before the old key its index will have changed. This is infuriating). I wrote a function to do that which you can find here, feel free to fork and improve.

    I guess if I was better at JS I'd make a keyframe object.