skip to Main Content

After Effects Expressions & JavaScript

framesToTime( )

The expression framesToTime( ) will convert a number to time. The time conversion is based on the frame rate of the composition, or a frame rate you set within the expression.

Expression form:

framesToTime(frames, fps=1.0/thisComp.frameDuration)

frames is a number representing a frame count. It does not have to be a whole number.

fps=1.0/thisComp.frameDuration is a number expressed in frames per second; in other words the frame rate. If this argument is omitted, and I usually do, the frame rate defaults to the composition’s settings.

thisComp is the current composition that contains the expression.

frameDuration returns the duration of a frame. 

Expression  explained:

The frames argument is the number of frames, usually represented by a variable that can change value, converted into time based on the frame rate. The frame rate is calculated by determining the duration of a single frame (frameDuration) and dividing 1 by that number.

Returns:

A number.

Example 1

You have a composition which contains an animation that is 60 frames long placed in your main composition. You want to be able to control that animation with a slider, and so you connect a slider with a value range of 0 through 59 (After Effects starts its  frame count at 0). In order for the animation to play properly, you need to activate Time Remapping on the animated composition (Layer > Time > Enable Time Remapping or right-click on animation compostion > Time > Enable Time Remapping) and connect the slider with an expression that converts frames (slider reading) to time (so the animated composition knows where on the timeline you want to be.

S=Pick whip the slider value here.;
framesToTime(S)

//This can also be written like the following

framesToTime(Pick whip the slider value here.)

EFFECT

As you move the slider, either manually or using keyframes, it determines what frame the animation is showing. By using the slider you can control the direction and speed of the animation throughout the main composition’s playing time.

Back To Top