Skip to main content

getVideoMetadata()v4.0.6

note

This function is meant to be used in Node.js applications. For browsers, use getVideoMetadata() from @remotion/media-utils instead.

Gets metadata about a video file in Node.js. Useful for calculating metadata on a server.

Example

ts
import { getVideoMetadata } from "@remotion/renderer";
 
const { width, height, fps, durationInSeconds } = await getVideoMetadata(
"./bunny.mp4"
);
ts
import { getVideoMetadata } from "@remotion/renderer";
 
const { width, height, fps, durationInSeconds } = await getVideoMetadata(
"./bunny.mp4"
);

Arguments

videoSource

string

A local video file path.

Return Value

The return value is an object with the following properties:

fps

number

The amount of frames per seconds the video has (framerate)

width

number

The width of the video in px.

height

number

The height of the video in px.

durationInSeconds

number

The time length of the video in seconds.

codecv4.0.8

string

One of 'h264' | 'h265' | 'vp8' | 'vp9' | 'av1' | 'prores' or 'unknown' if the codec is not officially supported by Remotion.

supportsSeekingv4.0.8

boolean

A prediction whether the video will be seekable in the browser. The algorithm is:

  1. If the codec is unknown, then the video is not seekable (false).
  2. If the video is shorter than 5 seconds, then it is seekable (true).
  3. If the codec is not h264, then it is seekable (true).
  4. The codec is now h264. If it supports Faststart (the moov atom is in front of the mdat atom), then it is seekable (true)
  5. Otherwise, it is not seekable (false).

If a video is not seekable, you might run into the "Non-seekable media" error.
This means that the video might fail to render if embedded in a <Video> tag and be slow if embedded in a <OffthreadVideo> tag.

You may consider re-encoding the video using FFmpeg to make it seekable.

See also