parseMedia()
Part of the @remotion/media-parser package.
available from v4.0.190
Unstable API: This package is experimental. We might change the API at any time, until we remove this notice.
Examples
Parsing a hosted videotsximport {parseMedia } from '@remotion/media-parser';constresult = awaitparseMedia ('https://example.com/my-video.mp4', {durationInSeconds : true,dimensions : true,});console .log (result .durationInSeconds ); // 10console .log (result .dimensions ); // {width: 1920, height: 1080}
Parsing a hosted videotsximport {parseMedia } from '@remotion/media-parser';constresult = awaitparseMedia ('https://example.com/my-video.mp4', {durationInSeconds : true,dimensions : true,});console .log (result .durationInSeconds ); // 10console .log (result .dimensions ); // {width: 1920, height: 1080}
Parsing a local filetsximport {parseMedia } from '@remotion/media-parser';import {nodeReader } from '@remotion/media-parser/node';constresult = awaitparseMedia ('/Users/jonnyburger/Downloads/my-video.mp4',{durationInSeconds : true,dimensions : true,},nodeReader ,);
Parsing a local filetsximport {parseMedia } from '@remotion/media-parser';import {nodeReader } from '@remotion/media-parser/node';constresult = awaitparseMedia ('/Users/jonnyburger/Downloads/my-video.mp4',{durationInSeconds : true,dimensions : true,},nodeReader ,);
API
Unstable API: This package is experimental. We might change the API at any time, until we remove this notice.
src
Either a local file path, or a URL.
If you pass a local file path, you must also pass nodeReader as the reader argument.
fields
An object specifying which fields you'd like to receive.
Possible fields are:
dimensions
{width: number, height: number}
The dimensions of the video.
durationInSeconds
number | null
The duration of the video in seconds.
boxes
The internal structure of the video. Unstable, internal data structure, refer to the TypeScript types to see what's inside.
fps
number | null
The frame rate of the video.
videoCodec
The video codec of the file.
If multiple video tracks are present, this will be the first video track.
One of "h264", "h265", "vp8", "vp9", "av1", "prores" or null (in case of an unknown codec).
audioCodec
The audio codec of the file.
If multiple audio tracks are present, this will be the first audio track.
One of "aac", "aiff", "vorbis", "opus" or null (in case of an unknown codec).
reader
A reader interface.
Default value: webReader, which uses fetch() to read the video.
If you pass nodeReader, you must also pass a local file path as the src argument.