Quantizing keyframes that are not on a whole value?

Hi Alon!
Question: After scaling keyframes on a layer sometimes they are not on full keyframe values but inbetween. And that sometimes causes glitches, esp. combined with time remapping.
Tried but couldn’t figure it out:

  1. Search all layers of selected comps for ALL keyframes (i guess there is no “all” so i would have to do this for at least the most common properties and extend as needed)
  2. Move keyframes that have not on an integer keyframe to the nearest integer

Thx in advance as always! :slight_smile:
Peter

Hi @thepetercoin,


This is an annoying problem with keyframes.
A while ago, I attempted to address this issue with an action called “snap to framerate” but it doesn’t really work correctly in every situation so its unreliable and needs to be fixed.



Actually there is “all” in Automation Toolkit, you can loop over all the layer properties and change only the properties with keyframes, so you don’t need to select custom properties ahead.



I usually strive to respond quickly and provide a detailed solution. However, this automation process is very tricky because it required a lot of trial and error to find the right solution for this problem. While it may sound simple, it’s essential to consider how to move the keyframes without overwriting others and determine the best approach to maintain timing.

Additionally, I had to find workarounds for issues with After Effects, which meant incorporating additional code into the automation to create an effective solution.



I created 2 versions for quantize the keyframes:


Quantize keyframes push forward -

This automation moves forward each keyframe that is in between frames to the closet next frame.
it will also push/offset the rest of the keyframes by the amount it moved each keyframe.

Quantize keyframes push forward

Pros:

  • The offset will preserve the original distance between the keyframes, helping to maintain the timing of the original animations.

Cons:

  • The offset will cause the last keyframes to become out of sync relative to the composition.

Download -

Quantize keyframes push forward.zip (3.4 KB)




Quantize keyframes squash forward -

This automation moves forward each keyframe that is in between frames to the closet next frame.
it will push/offset the rest of the keyframes only if it cant move a keyframe forward without overwriting another keyframe.

Quantize keyframes squash forward

Pros:

  • The offset will preserve the timing of keyframes relative to the composition, and it will try not to change the duration of the animation.

Cons:

  • The original distance between the keyframes might be shortened, which can change the timing of the original animations to appear faster.

Download -

Quantize keyframes squash forward.zip (3.4 KB)




I think that in most cases, I would prefer the ‘Quantize keyframes squash forward’ option, but I can imagine some cases where ‘Quantize keyframes push forward’ would be better.

Currently it works only on the active comp but it can be run on multiple comps at once easily.
Please let me know if you have questions, and if it fixed your problem.

Hey Alon, sry for the late reply - pretty busy around here.
Thank you SO much for the detailed explanation! Will test it asap :slight_smile:
All the best from Austria,
Peter