getVideoMetadata()v4.0.6
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 ,VideoMetadata } from "@remotion/renderer";constvideoMetadata :VideoMetadata = awaitgetVideoMetadata ("./bunny.mp4");const {width ,height ,fps ,durationInSeconds ,codec ,supportsSeeking ,colorSpace ,audioCodec ,audioFileExtension ,} =videoMetadata ;
ts
import {getVideoMetadata ,VideoMetadata } from "@remotion/renderer";constvideoMetadata :VideoMetadata = awaitgetVideoMetadata ("./bunny.mp4");const {width ,height ,fps ,durationInSeconds ,codec ,supportsSeeking ,colorSpace ,audioCodec ,audioFileExtension ,} =videoMetadata ;
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.
codec
v4.0.8
string
One of 'h264' | 'h265' | 'vp8' | 'vp9' | 'av1' | 'prores'
or 'unknown'
if the codec is not officially supported by Remotion.
supportsSeeking
v4.0.8
boolean
A prediction whether the video will be seekable in the browser. The algorithm is:
- If the codec is
unknown
, then the video is not seekable (false
). - If the video is shorter than 5 seconds, then it is seekable (
true
). - If the codec is not
h264
, then it is seekable (true
). - The codec is now
h264
. If it supports Faststart (themoov
atom is in front of themdat
atom), then it is seekable (true
) - 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.
colorSpace
v4.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
v4.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
v4.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.