Back to Remotion

getVideoMetadata()

packages/docs/docs/renderer/get-video-metadata.mdx

4.0.4645.3 KB
Original Source

getVideoMetadata()<AvailableFrom v="4.0.6" />

:::note Deprecated.
Better solution: Get metadata using Mediabunny :::

:::note Only works in Node.js and Bun. :::

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

Example

ts
import {getVideoMetadata, VideoMetadata} from '@remotion/renderer';

const videoMetadata: VideoMetadata = await getVideoMetadata('/Users/john/Documents/bunny.mp4');

const {width, height, fps, durationInSeconds, codec, supportsSeeking, colorSpace, audioCodec, audioFileExtension, pixelFormat} = videoMetadata;

:::info Pass an absolute path to getVideoMetadata(). URLs are not supported. :::

Arguments

videoSource

string

A local video file path.

options?

logLevel?

<Options id="log" />

binariesDirectory?<AvailableFrom v="4.0.120" />

<Options id="binaries-directory" />

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.

codec<AvailableFrom v="4.0.8" />

string

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

supportsSeeking<AvailableFrom v="4.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 <Html5Video> tag and be slow if embedded in a <OffthreadVideo> tag.

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

colorSpace<AvailableFrom v="4.0.28"/>

One of rgb, bt601, bt709, bt2020-ncl, bt2020-cl, fcc, bt470bg, smpte170m, smpte240m, ycgco, smpte2085, chroma-derived-ncl, chroma-derived-cl, ictcp or unknown.

audioCodec<AvailableFrom v="4.0.49"/>

If the video has no audio track, it is null. If the audio codec is unknown to Remotion, it is "unknown".

Otherwise, it is one of "opus" | "aac" | "mp3" | "pcm-f16le" | "pcm-f24le" | "pcm-f32be" | "pcm-s16be" | "pcm-s16le" | "pcm-f32le" | "pcm-s32be" | "pcm-s32le" | "pcm-s64be" | "pcm-s64le" | "pcm-u16be" | "pcm-u16le" | "pcm-u24be" | "pcm-u24le" | "pcm-u32be" | "pcm-u32le" | "pcm-u8" | "pcm-f64be" | "pcm-s24be" | "pcm-s24le" | "pcm-s8" | "pcm-s16be-planar" | "pcm-s8-planar" | "pcm-s24le-planar" | "pcm-s32le-planar" | "unknown"

audioFileExtension<AvailableFrom v="4.0.49"/>

If the video has no audio track or is unknown to Remotion, it is null. Otherwise it is the appropriate file extension for the audio codec, e.g. "mp3". The . is not included.

pixelFormat<AvailableFrom v="4.0.78"/>

One of yuv420p, yuyv422, rgb24, bgr24, yuv422p, yuv444p, yuv410p, yuv411p, yuvj420p, yuvj422p, yuvj444p, argb, rgba, abgr, bgra, yuv440p, yuvj440p, yuva420p, yuv420p16le, yuv420p16be, yuv422p16le, yuv422p16be, yuv444p16le, yuv444p16be, yuv420p9be, yuv420p9le, yuv420p10be, yuv420p10le, yuv422p10be, yuv422p10le, yuv444p9be, yuv444p9le, yuv444p10be, yuv444p10le, yuv422p9be, yuv422p9le, yuva420p9be, yuva420p9le, yuva422p9be, yuva422p9le, yuva444p9be, yuva444p9le, yuva420p10be, yuva420p10le, yuva422p10be, yuva422p10le, yuva444p10be, yuva444p10le, yuva420p16be, yuva420p16le, yuva422p16be, yuva422p16le, yuva444p16be, yuva444p16le, yuva444p, yuva422p, yuv420p12be, yuv420p12le, yuv420p14be, yuv420p14le, yuv422p12be, yuv422p12le, yuv422p14be, yuv422p14le, yuv444p12be, yuv444p12le, yuv444p14be, yuv444p14le, yuvj411p, yuv440p10le, yuv440p10be, yuv440p12le, yuv440p12be, yuv420p9, yuv422p9, yuv444p9, yuv420p10, yuv422p10, yuv440p10, yuv444p10, yuv420p12, yuv422p12, yuv440p12, yuv444p12, yuv420p14, yuv422p14, yuv444p14, yuv420p16, yuv422p16, yuv444p16, yuva420p9, yuva422p9, yuva444p9, yuva420p10, yuva422p10, yuva444p10, yuva420p16, yuva422p16, yuva444p16, yuva422p12be, yuva422p12le, yuva444p12be, yuva444p12le, unknown.

Compatibility

<CompatibilityTable chrome={false} firefox={false} safari={false} nodejs={true} bun={true} serverlessFunctions={false} clientSideRendering={false} serverSideRendering={true} player={false} studio={false} />

See also