Skip to main content
Bradley Morris
Participating Frequently
October 9, 2021
Question

Rounding Time-Remapped Frames to Whole Numbers

  • October 9, 2021
  • 1 reply
  • 1835 views

I have applied my time remap, ALT-clicked the stopwatch, then gone Animation/ Keyframe Assistant/ Convert Expression to Keyframes.  However, I need to round these keyframe values up and down to whole numbers.

 

Is there an expression I can run after or along with the time remap which will result in key values of whole numbers?

 

I have tried playing with math.round, math.floor and timeToFrames, but I truly have no idea what I'm doing!  Any help would be greatly appreciated.  Thank you -

 

 

This topic has been closed for replies.

1 reply

Community Expert
October 9, 2021

Time remapping keyframes are based on seconds. If you round each keyframe to a whole number. Are you trying to round to the nearest frame? Changing the time display from timecode to will change how the numbers appear in the timeline, but any time you use an expression to drive time, no matter what the frame rate, if you generate a 2.00 you get 2 seconds if the comp frame rate is 30 or if the frame rate is 120 fps. Enter 2 in and expression and the time will always be 2 seconds.

 

Why do you want to round the keyframes to whole numbers? If you time remapped video footage, frames are going to be blended. If you time remapped a pre-comp that contains any kind of keyframe animation, there are n blended frames. For example, if you add a solid to the timeline and then animate the layer so that it moves 200 frames in 1 second, then you precompose the layer and time remap it you can have the layer move the same 200 frames but make it take 20 seconds and every frame will be perfect and there are no blended or duplicated frames.

 

Please explain your desired design goals a little clearer and we can probably help you figure out how to get exactly what you need. 

 

Bradley Morris
Participating Frequently
October 11, 2021

Hi, Rick -

Thank you for such a considered response.  Let me try to earn a bit more of your expertise by filling in a few details.

 

Yes, time remapping is based on seconds, but ultimately the remap is selecting from a limited number of frames in an image sequence.  What I need to do is round up or down to point to the frame that any given remapped key is actually referencing [barring the use of some artificial interpolation such as frame-blending].  Let me give you a real-world instance that I am currently working with.

 

I have been given a 246 frame sequence with a time remap applied.  If I bake out that curve, the values returned are, as expected, purely mathematical and more often than not yield fractional results expressed in decimals.  And so, for instance, on frame 50, the remapped key has a value of 3.09756 seconds, which, at 30 fps, is 92.9268.  Except that, in the real world, there is no frame 92.9268.  There is a frame 92 and there is a frame 93, but no other frame exists between the two. 

 

All I am trying to do is find a way to round that value up or down before exporting the data out of After Effects.  I have seen an expression that rounds X and Y values [before applying Animation/ Keyframe Assistant/ Convert Expression to Keyframes] when calculating for position.  I need to do basically the same thing, only to frame numbers.

 

I hope this helps clarify my goal!  Thank you in advance for any help you may be able to offer -

bradley

Bradley Morris
Participating Frequently
October 12, 2021

It's not clear on how you're planning on doing the exporting of your data, but if you want the frame number that AE will use corresponding to a given decimal time (in seconds), you can just use timeToFrames(your_decimal_time). Sorry if that doesn't help...


Hi, Dan.  I am simply copying the baked keys and pasting them into a text file, which is then read into Maya, recreating After Effects' time remap as a Maya timewarp curve.  The non-zero values after the decimal are throwing things off because, as I mentioned earlier, there are no frames between frames!  

 

In 3D, of course, you can subdivide between two positions almost infinitely, but the image sequence has no such data.  You are either on frame 112 or 113 [for instance].  And if you need to align to frame 113 of an image sequence, then being on frame 112.4 will do you no good!  If you see what I mean.

 

And yes, I agree... from what little I have had the chance to learn about AE expressions in the last day or so, timeToFrames stuck out as a likely solution.  I simply do not know enough about writing expressions to get it to work without erroring out.  Again, all I'm trying to do - either before baking the time remap curve, or after - is round those key values up or down to a whole number.  I will then copy those values into a text file and parse that in Maya.

 

Right now, if I add timeToFrames following the timeRemap expresson, I still end up with non-zero decimal values on each key after running Convert Expression to Keyframes.  If you have any suggestion as to how to write this correctly, I will be forever in your debt -