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 } from "@remotion/renderer";const {width ,height ,fps ,durationInSeconds } =awaitgetVideoMetadata ("./bunny.mp4");
ts
import {getVideoMetadata } from "@remotion/renderer";const {width ,height ,fps ,durationInSeconds } =awaitgetVideoMetadata ("./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.
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
.