Skip to main content

getLottieMetadata()

Part of the @remotion/lottie package.

Using this function, you can get the basic metadata such as dimensions, duration and framerate of a Lottie animation.

Animation.tsx
tsx
import { getLottieMetadata } from "@remotion/lottie";
 
// animationData is a JSON object, can be imported from a .json file, remote file or using staticFile()
const metadata = getLottieMetadata(animationData);
 
/*
{
durationInFrames: 90,
durationInSeconds: 3.0030030030030037,
fps: 29.9700012207031,
height: 1080,
width: 1920,
}
*/
Animation.tsx
tsx
import { getLottieMetadata } from "@remotion/lottie";
 
// animationData is a JSON object, can be imported from a .json file, remote file or using staticFile()
const metadata = getLottieMetadata(animationData);
 
/*
{
durationInFrames: 90,
durationInSeconds: 3.0030030030030037,
fps: 29.9700012207031,
height: 1080,
width: 1920,
}
*/

API

The function takes one argument, a JavaScript object that adheres to the Lottie schema.

Return value

If the metadata cannot be parsed, this function returns null.

If the metadata can be parsed, it returns an object with the following properties:

height

The natural height of the animation in pixels.

width

The natural width of the animation in pixels.

durationInSeconds

The duration of the animation in seconds, if the fps from this object is used.

durationInFrames

The duration of the animation in frames, if the fps from this object is used.

note

This value is rounded down to the closest integer, since Remotion does not support non-integer values for durationInFrames.

fps

The natural framerate of the Lottie animation.

See also