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 videotsx
import {parseMedia } from '@remotion/media-parser';constresult = awaitparseMedia ({src : 'https://example.com/my-video.mp4',fields : {durationInSeconds : true,dimensions : true,},});console .log (result .durationInSeconds ); // 10console .log (result .dimensions ); // {width: 1920, height: 1080}
Parsing a hosted videotsx
import {parseMedia } from '@remotion/media-parser';constresult = awaitparseMedia ({src : 'https://example.com/my-video.mp4',fields : {durationInSeconds : true,dimensions : true,},});console .log (result .durationInSeconds ); // 10console .log (result .dimensions ); // {width: 1920, height: 1080}
Parsing a local filetsx
import {parseMedia } from '@remotion/media-parser';import {nodeReader } from '@remotion/media-parser/node';constresult = awaitparseMedia ({src : '/Users/jonnyburger/Downloads/my-video.mp4',fields : {durationInSeconds : true,dimensions : true,},reader :nodeReader ,});
Parsing a local filetsx
import {parseMedia } from '@remotion/media-parser';import {nodeReader } from '@remotion/media-parser/node';constresult = awaitparseMedia ({src : '/Users/jonnyburger/Downloads/my-video.mp4',fields : {durationInSeconds : true,dimensions : true,},reader :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.
Any rotation is already applied - the dimensions are like a media player would show them.
Use unrotatedDimensions
to get the dimensions before rotation.
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'
, 'mp3'
, 'aiff'
, 'opus'
, 'pcm'
, 'unknown'
(audio is there but not recognized) or null
(in case of no audio detected).
tracks
Returns two arrays videoTracks
and audioTracks
.
The data structure of them is not yet stable.
unrotatedDimensions
{width: number, height: number}
The dimensions of the video before rotation.
rotation
number
The rotation of the video in degrees (e.g. -90
for a 90° counter-clockwise rotation).
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.