Copy link to clipboard
Copied
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 -
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
By far the easiest way to get to a specific frame at a specific time is to use an Expression Control Slider and multiply the value by the comp frame duration. This works perfectly if the Composition frame rate matches the footage frame rate. Set the slider to Frame 29 and the footage will be at frame 29. All you do is match the frame rate of the comp to the frame rate of the footage (image sequence), enable time remapping, then add an expression control slider to the footage layer, enable Time Remapping (Alt/Option + Ctrl/Cmnd + t), and then add the following expression:
effect("Frames")("Slider")*thisComp.frameDuration;
I named the Slider "Frames" and all you have to do is set the slider keyframes to whole numbers.
If you want all of the in-between frames to also be exactly on the nearest frame you could modify the expression like this to eliminate all blended frames:
frm = effect("Frames")("Slider");
Math.round(frm) * thisComp.frameDuration;
If your footage frame rate does not match the desired comp frame rate then the easiest fix is to interpret the footage in the Project Panel and make it match the comp's frame rate. That way a comp frame will always match a footage frame.
If for some crazy reason you have to keep the original frame rate for the footage and put that footage in a comp with a different frame rate then you need to figure out the frame duration of the original footage and just multiply that number by the slider value.
For example, if your footage was 23.976 fps then the frame duration would be 0.04170837504170837. That is pretty close because there are more decimal points in most frame rates, but it would get you to the closest frame if the comp and footage frame rates don't match. If you are time remapping, then the original footage frame rate doesn't make any difference so the simplest solution is to just match the comp and footage frame rate and use the expression control slider.
Hope this helps. Using the slider control is by far the easiest solution.
Copy link to clipboard
Copied
Thank you, Rick!
As I am completely unfamiliar with sliders in AE, I will have to learn a bit about them first. Image sequence or movie frame rates will always match the comp [30 fps], so that should never be an issue.
I'm not sure if you are saying that I have to move the slider to each frame to get the whole number value, because I need it to apply the rounding to all frames as it's baked by Converting the Expression to Keyframes. I suspect my lack of experience or understanding of sliders has a lot to do with my confusion on that point.
I will give this a try and let you know what comes of it! Thank you again, sir -
b
Copy link to clipboard
Copied
An expression control slider is just a way of introducing a value into an expression. When you enable time remapping there are two keyframes added, one at the first frame of the source footage and one at the end or the start of the last frame. Every frame then has a value.
If you add an expression control slider to a footage layer that has time remapping enabled and you tie the value directly to the slider 0 on the slider will be 0 seconds for the footage. 2 on the slider will give you 2 seconds on the footage. If the frame rate is 30 fps then moving the slider to 2 move the video to frame 60. That means if you set the first keyframe for the slider to 0 and that keyframe is at the first frame of the composition the video will start at frame 0 and stay there forever until you move down the timeline and set a new keyframe to something like 2 somewhere down the timeline. If the keyframes for the slider are 10 seconds apart then the footage will now start at frame 0 and move to frame 60 over the next 10 seconds.
Multiplying the slider value by the frame duration just changes the slider values so they represent frames instead of seconds. This allows you to pick start and end frames by frame number instead of time.
With only 2 keyframes in the sample project, the first frame will be frame 0, the next frame will be 30. something until you get to the next full frame. The next full frame, frame 31, will be frame 5 in the timeline, then the next full frame, frame 2, will be at frame 10 and so on until you get to frame 60 or 0:00:02:00 at 0:00:10:00 in the timeline.
Did you follow that?
Throwing in Math.round means that you will get frame 0 for the first 2 frames, then frame 1 for the next 5 frames and frame 2 for the next and so on until you get to frame 60 at 0:09:28.
Here's the graph editor showing the results with the rounding vs the time value with no rounding. Notice the stair-steps.
If all you want to do is assure that every frame in the comp is not a blended frame, all you have to do is add the expresson control slider.
Now, if you convert the expression to keyframes you will have whole frame values for each frame. I don't know what you want to do with that information, but that is the way to get whole frame values for all your keyframes. It even works if you put in a bunch of easing on the Slider Control keyframes. You can get something like this:
I hope that makes a little more sense. Using the slider and math.Round will give you exact frame numbers for every frame of the composition.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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 -
Copy link to clipboard
Copied
OK, so once you turn on Time Remapping for your layer you could add a null layer, add a slider to that, and add an expression to the slider that looks like this:
timeToFrames(thisComp.layer("(your time remap layer)").timeRemap)
then convert that to keyframes and you should end up with whole numbers for your keyframe values. I'm still not sure that's what you're after though...
Copy link to clipboard
Copied
I would add the expression control slider to perform the time changes you need, use the second expression, then convert the expression to keyframes. See my Graph. You can have any speed changes you need in the project and export a precise frame number to Maya.
If it was my project I would let Frame Blending do its job and render a new image sequence to use in Maya. That way, the final animation will look smoother by a bunch. If you need drastic speed changes then invest in something like Twixtor and just render a new image sequence to use in Maya.
The other option is to do linear animation in Maya, import that image sequence in AE, import the original image sequence, pre-compose both, then time remap the entire new sequence using frame blending (vector may be better, you will have to experiment) and end up with a nice smooth animation instead of one that jerks from frame to frame.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now