Skip to main content
Participating Frequently
January 24, 2024
Question

Snapping all keysframes to a full frame

  • January 24, 2024
  • 3 replies
  • 1279 views

So....

 

I  wasn't paying attention to a comps settings and did a whole bunch of animation in a comp thats 27.97 fps as opposed to a 24 fps. When I set it back to 24 fps the keys all end up on half key frames and its a bit of a mess. Is there anyway to select the lot and have them all pop to the nearest frame?

 

I had a quick google around and found asu_NudgeKeyFrames_selectedlayersonly.jsx

but I'm guessing it could be old as doenst seem to be working with the latest version of ae.

 

Any help would be greatfully appriciated, thanks 

3 replies

Mathias Moehl
Community Expert
Community Expert
June 17, 2025

One of my BeatEdit users just had the same question, since beat markers and keyframes generated by BeatEdit in sync with the beat have subframe accuracy and he didn't ant that for some reason.

I noticed that the script above suggested by Airweb does not preserve the keyframe easing. Therefore I created tools for my (paid) extension Automation Blocks for After Effects now, which can snap both markers and keyframes to frame boundaries (and preserve all marker details and keyframe easing):


Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Community Expert
January 25, 2024

Keyframes are always based on time. When you change the frame rate, they may not line up with the start of a frame, but the change in value will still happen at the same time, rounded to the nearest frame. Snapping a keyframe to the start of a frame will not change the animation's timing or appearance. The only thing that will change is the position of the keyframe relative to the start of the frame. Snapping every keyframe will not change the rendered movie's timing or look. In my opinion, it's a waste of time. 

 

Movies that were shot on film at 24 fps and broadcasted at 29.97 fps still look like movies instead of videos.

Michelangelo De Cia
Known Participant
November 16, 2024

Hey, I agree with Rick, snapping keyframes to the nearest frame is usually not needed. However, if you have a bunch of keyframes and some are set to linear and some to hold, and the hold ones are not snapped to the frame, you might get weird results if motion motion blur in on. That's a pretty specific case but i now have to move around 50 keyframe manually, it would be usefull to have a native ae command to do it:)

Legend
January 24, 2024

Try this, you can select multiple properties at once:

 

AdjustKeyframesToComposition.jsx

 

var proj = app.project;
var thisComp = proj.activeItem;
var props = thisComp.selectedProperties;
if (!props.length) {
  alert('Please select at least 1 property.');
} else {
  app.beginUndoGroup("undo");

  for (var propIndex = 0; propIndex < props.length; propIndex++) {
    var prop = props[propIndex];
    for (var keyIndex = 1; keyIndex <= prop.numKeys; keyIndex++) {
      var v = prop.keyValue(keyIndex);
      var t = Math.floor(thisComp.frameRate * prop.keyTime(keyIndex)) / thisComp.frameRate;
      prop.removeKey(keyIndex);
      prop.setValueAtTime(t, v);
    }
  }
  app.endUndoGroup();
}