Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions keyValue() for time remapping?

  • keyValue() for time remapping?

    Posted by Jake Nelson-dooley on February 29, 2012 at 4:49 pm

    Hi team,
    I got a complex project that needs to go from 30fps to 23.976 fps. As part of that, I’m trying to get all keyframes, including Time Remapping keyframes, to sit on their exact frame, not in-between two frames, as sometimes happens.

    I found this free script, Nudge Keyframes, by Anders Sunstedt:
    https://sundstedt.se/blog/?p=661

    It works great for Position, Rotation, Scale etc, but not Time Remapping. Is it possible for me to modify this to address Time Remapping as well?

    Here’s an excerpt from the .jsx, where the position keyframes are being nudged:

    or (var j = 1; j <= myLayers[i].position.numKeys; j++)
    {
    // myNearestKeyIndex = layers[i].position.nearestKeyIndex(0);
    var mykeyTime = myLayers[i].position.keyTime(j); // j is a keyframe nr

    // I want to set the time value of keyfram (j)
    nearestTime = Math.round(mykeyTime*fps)/fps; // round to nearest keyframe value;

    // Copy the position value (x,y,z) of keyframe(j)
    var posValueCopy = myLayers[i].position.keyValue(j);

    // Delete the keyframe
    myLayers[i].position.removeKey(j);

    // Add a replacement key for removed key at correct position
    myLayers[i].position.addKey(nearestTime);

    // Set the position value of keyframe k to the stored position value of deleted keyframe
    myLayers[i].position.setValueAtKey(j, posValueCopy);

    }

    Jake Nelson-dooley replied 14 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Jake Nelson-dooley

    February 29, 2012 at 7:10 pm

    I’ve figured that I can use the method from the Nudge script along with timeRemap.keyTime()

    This seems to loop through the keyframes and copy, delete, paste onto the next nearest frame.

    The problem I’m having now is if there are keyframes one-after-another. Then the script seems to create gaps. Anders mentioned this was a caveat of the script…

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy