🎥 Make videos programmatically with React
add to docs
Jonny Burgerc2af16d8c512
diff --git a/packages/docs/docs/media-parser/TableOfContents.tsx b/packages/docs/docs/media-parser/TableOfContents.tsxindex cf32ad29a6..c1b7132c44 100644--- a/packages/docs/docs/media-parser/TableOfContents.tsx+++ b/packages/docs/docs/media-parser/TableOfContents.tsx@@ -10,6 +10,10 @@ export const MediaParserGuideTableOfContents: React.FC = () => {<strong>Getting video metadata</strong><div>Simple examples of extracting video metadata</div></TOCItem>+ <TOCItem link="/docs/media-parser/fields">+ <strong>Available fields</strong>+ <div>Information you can get using the media parser</div>+ </TOCItem><TOCItem link="/docs/media-parser/fast-and-slow"><strong>Fast and slow operations</strong><div>Efficently use parseMedia()</div>@@ -30,6 +34,12 @@ export const MediaParserGuideTableOfContents: React.FC = () => {<strong>Runtime support</strong><div>Where you can run Media Parser</div></TOCItem>+ <TOCItem link="/docs/media-parser/foreign-file-types">+ <strong>Foreign file types</strong>+ <div>+ Get information from the errors when passing unsupported file types+ </div>+ </TOCItem><TOCItem link="/docs/media-parser/webcodecs"><strong>WebCodecs</strong><div>How Media Parser integrates with WebCodecs</div>diff --git a/packages/docs/docs/media-parser/fields.mdx b/packages/docs/docs/media-parser/fields.mdxnew file mode 100644index 0000000000..1602cdfbca--- /dev/null+++ b/packages/docs/docs/media-parser/fields.mdx@@ -0,0 +1,210 @@+---+image: /generated/articles-docs-media-parser-fields.png+id: fields+title: Available Fields+slug: /media-parser/fields+crumb: '@remotion/media-parser'+---++The following fields are available in [`parseMedia()`](/docs/media-parser/parse-media):++### `dimensions`++_`{width: number, height: number} | null`_++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.++If the media passed is an audio file, this will return `null`.++### `durationInSeconds`++_number | null_++The duration of the video in seconds.+Only returns a non-null value if the duration is stored in the metadata.++### `slowDurationInSeconds`++_number_++The duration of the video in seconds, but it is guaranteed to return a value.+If needed, the entire video file is read to determine the duration.++### `name`++_string_++The name of the file.++### `container`++_"mp4" | "webm" | "avi" | "transport-stream" | "mp3" | "aac" | "wav" | "flac"_++The container of the file.++### `size`++_number | null_++The size of the input in bytes.++### `mimeType`++_string | null_++The MIME type of the file that was returned when the file was fetched.+Only available if using the `fetchReader` or `webFileReader`.++### `structure`++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.+Only returns a non-null value if the frame rate is stored in the metadata.++### `slowFps`++_number_++The frame rate of the video, but it is guaranteed to return a value.+If needed, the entire video file is read to determine the frame rate.++### `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'`, `'flac'`, `'unknown'` (audio is there but not recognized) or `null` (in case of no audio detected).++### `metadata`++Metadata fields such as ID3 tags or EXIF data.+See [metadata](/docs/media-parser/tags) for more information.++### `location`++The location of the video was shot. Either `null` if not available or:++- `latitude`: The latitude of the location+- `longitude`: The longitude of the location+- `altitude`: The altitude of the location (can be `null`)+- `horizontalAccuracy`: The horizontal accuracy of the location (can be `null`)++### `tracks`++Returns an object of two two arrays `videoTracks` and `audioTracks`.+The data structure of them is not yet stable.++### `keyframes`++Return type: <TsType type="MediaParserKeyframe[] | null" source="@remotion/media-parser" />++An array of keyframes. Each keyframe has the following structure:++- `presentationTimeInSeconds`: The time in seconds when the keyframe should be presented+- `decodingTimeInSeconds`: The time in seconds when the keyframe should be decoded+- `positionInBytes`: The position in bytes where the keyframe is located in the file+- `sizeInBytes`: The size of the keyframe in bytes+- `trackId`: The ID of the track the frame belongs to++Only being returned if the keyframe information are stored in the metadata, otherwise `null`.++### `slowKeyframes`++Return type: <TsType type="MediaParserKeyframe[]" source="@remotion/media-parser" />++An array of keyframes, same as [`keyframes`](#keyframes), but it is guaranteed to return a value.++Will read the entire video file to determine the keyframes.++### `slowNumberOfFrames`++_number_++The number of video frames in the media.+Will read the entire video file to determine the number of frames.++### `unrotatedDimensions`++_`{width: number, height: number}`_++The dimensions of the video before rotation.++### `isHdr`++_`boolean`_++Whether the video is in HDR (High dynamic range).++### `rotation`++_number_++The rotation of the video in degrees (e.g. `-90` for a 90° counter-clockwise rotation).++### `images`++Return type: <TsType type="MediaParserEmbeddedImage[]" source="@remotion/media-parser" />++Embedded images in the file, for example an album cover inside an MP3.+Each array element has the following fields:++- `mimeType`: The MIME type of the image, or `null`+- `description`: A description of the image, or `null`+- `data`: The image data as a `Uint8Array`++### `sampleRate`++_number | null_++The audio sample rate, if there is an audio track.++### `numberOfAudioChannels`++_number | null_++The number of audio channels, if there is an audio track.++### `slowAudioBitrate`++_number_++The audio bitrate in bits per second. `null` if there is no audio track.++:::note+1 byte is 8 bits.+:::++### `slowVideoBitrate`++_number | null_++The video bitrate in bits per second. `null` if there is no video track.++:::note+1 byte is 8 bits.+:::++### `m3uStreams`++Only for .m3u8, this will return a non-`null` value if the file is a playlist.++An array of objects with the following fields:++- `bandwidth`: The bandwidth of the stream. May be `null`.+- `averageBandwidth`: The average bandwidth of the stream. May be `null`.+- `resolution`: The resolution of the stream. May be `null`.+- `codecs`: The codec strings of the stream as an array May be `null`.+- `url`: The URI of the stream+- `id`: A unique identifier that Remotion gives the streamdiff --git a/packages/docs/docs/media-parser/format-support.mdx b/packages/docs/docs/media-parser/format-support.mdxindex 4048ee1722..2b86613eee 100644--- a/packages/docs/docs/media-parser/format-support.mdx+++ b/packages/docs/docs/media-parser/format-support.mdx@@ -48,7 +48,11 @@ Is supported.## HLS (`.m3u8`)-Is not supported, but planned.+Is supported.++## MPEG-DASH (`.mpd`)++Is planned to be supported.## Other container formatsdiff --git a/packages/docs/docs/media-parser/index.mdx b/packages/docs/docs/media-parser/index.mdxindex 0904c7d82d..b8ffca10d8 100644--- a/packages/docs/docs/media-parser/index.mdx+++ b/packages/docs/docs/media-parser/index.mdx@@ -10,7 +10,7 @@ import {TableOfContents, MediaParserGuideTableOfContents} from './TableOfContent_available from v4.0.190_-This is an experimental package that parses video and other media files in order to extract relevant metadata.+This is a package that parses video and audio files to extract metadata and samples.:::warning**Unstable API**: This package is experimental. The API may change in the future.@@ -19,13 +19,16 @@ The API for getting video metadata is stable and may be used in production.Design goals:-- Support as many relevant containers as possible - currently: `.mp4`, `.mov`, `.webm`, `.mkv`, `.avi`, `.ts`, `.mp3`, `.wav`, `.aac` and `.flac`.+- [Support all relevant multimedia containers](/docs/media-parser/format-support): `.mp4`, `.mov`, `.webm`, `.mkv`, `.avi`, `.m3u8`, `.ts`, `.mp3`, `.wav`, `.aac` and `.flac`.+- [Easily get various information](/docs/media-parser/fields) from multimedia files- [Work in the browser, and server runtimes (Node.js, Bun, Edge, etc.)](/docs/media-parser/runtime-support)-- [Enable powerful WebCodecs use cases](/docs/media-parser/webcodecs)-- [Fine-grained querying, only download as much data as necessary](/docs/media-parser/fast-and-slow)+- [Satisfy your query with minimal fetching](/docs/media-parser/fast-and-slow)- [Functional TypeScript API](/docs/media-parser/parse-media)- [Be useful when passing unsupported media](/docs/media-parser/foreign-file-types)-- Solve problems that are relevant for Remotion users+- [Extract samples and enable WebCodecs use cases](/docs/media-parser/webcodecs)+- [Pausable, resumable and cancellable](/docs/media-parser/pause-resume-abort)+- Seeking - continue parsing in a different section of the file (not yet implemented)+- No dependencies## Installationdiff --git a/packages/docs/docs/media-parser/metadata.mdx b/packages/docs/docs/media-parser/metadata.mdxindex 0f60f022e2..26eae94519 100644--- a/packages/docs/docs/media-parser/metadata.mdx+++ b/packages/docs/docs/media-parser/metadata.mdx@@ -80,7 +80,7 @@ console.log(result.dimensions); // {width: 1920, height: 1080}You can read the duration, the dimensions, the framerate, the container format, the codecs, the ID3 tags and more information from a video file.-See [Available Fields](/docs/media-parser/parse-media#available-fields) for a complete list.+See [Available Fields](/docs/media-parser/fields) for a complete list.## Getting metadata as soon as possiblediff --git a/packages/docs/docs/media-parser/parse-media.mdx b/packages/docs/docs/media-parser/parse-media.mdxindex 8c611fa698..6e4ec303d8 100644--- a/packages/docs/docs/media-parser/parse-media.mdx+++ b/packages/docs/docs/media-parser/parse-media.mdx@@ -63,7 +63,7 @@ If you pass a `File` object, you must also pass [`webFileReader`](/docs/media-paAn object specifying which fields you'd like to receive.If you like to receive the field, pass `true` as the value.-See [Available Fields](#available-fields) for a list of available fields.+See [Available Fields](/docs/media-parser/fields) for a list of available fields.### `reader?`@@ -154,211 +154,6 @@ Default value: `"info"`, which logs only important information.Acknowledge the [Remotion License](https://remotion.dev/license) to make the console message disappear.-## Available fields--The following fields are queryable:--### `dimensions`--_`{width: number, height: number} | null`_--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.--If the media passed is an audio file, this will return `null`.--### `durationInSeconds`--_number | null_--The duration of the video in seconds.-Only returns a non-null value if the duration is stored in the metadata.--### `slowDurationInSeconds`--_number_--The duration of the video in seconds, but it is guaranteed to return a value.-If needed, the entire video file is read to determine the duration.--### `name`--_string_--The name of the file.--### `container`--_"mp4" | "webm" | "avi" | "transport-stream" | "mp3" | "aac" | "wav" | "flac"_--The container of the file.--### `size`--_number | null_--The size of the input in bytes.--### `mimeType`--_string | null_--The MIME type of the file that was returned when the file was fetched.-Only available if using the `fetchReader` or `webFileReader`.--### `structure`--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.-Only returns a non-null value if the frame rate is stored in the metadata.--### `slowFps`--_number_--The frame rate of the video, but it is guaranteed to return a value.-If needed, the entire video file is read to determine the frame rate.--### `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'`, `'flac'`, `'unknown'` (audio is there but not recognized) or `null` (in case of no audio detected).--### `metadata`--Metadata fields such as ID3 tags or EXIF data.-See [metadata](/docs/media-parser/tags) for more information.--### `location`--The location of the video was shot. Either `null` if not available or:--- `latitude`: The latitude of the location-- `longitude`: The longitude of the location-- `altitude`: The altitude of the location (can be `null`)-- `horizontalAccuracy`: The horizontal accuracy of the location (can be `null`)--### `tracks`--Returns an object of two two arrays `videoTracks` and `audioTracks`.-The data structure of them is not yet stable.--### `keyframes`--Return type: <TsType type="MediaParserKeyframe[] | null" source="@remotion/media-parser" />--An array of keyframes. Each keyframe has the following structure:--- `presentationTimeInSeconds`: The time in seconds when the keyframe should be presented-- `decodingTimeInSeconds`: The time in seconds when the keyframe should be decoded-- `positionInBytes`: The position in bytes where the keyframe is located in the file-- `sizeInBytes`: The size of the keyframe in bytes-- `trackId`: The ID of the track the frame belongs to--Only being returned if the keyframe information are stored in the metadata, otherwise `null`.--### `slowKeyframes`--Return type: <TsType type="MediaParserKeyframe[]" source="@remotion/media-parser" />--An array of keyframes, same as [`keyframes`](#keyframes), but it is guaranteed to return a value.--Will read the entire video file to determine the keyframes.--### `slowNumberOfFrames`--_number_--The number of video frames in the media.-Will read the entire video file to determine the number of frames.--### `unrotatedDimensions`--_`{width: number, height: number}`_--The dimensions of the video before rotation.--### `isHdr`--_`boolean`_--Whether the video is in HDR (High dynamic range).--### `rotation`--_number_--The rotation of the video in degrees (e.g. `-90` for a 90° counter-clockwise rotation).--### `images`--Return type: <TsType type="MediaParserEmbeddedImage[]" source="@remotion/media-parser" />--Embedded images in the file, for example an album cover inside an MP3.-Each array element has the following fields:--- `mimeType`: The MIME type of the image, or `null`-- `description`: A description of the image, or `null`-- `data`: The image data as a `Uint8Array`--### `sampleRate`--_number | null_--The audio sample rate, if there is an audio track.--### `numberOfAudioChannels`--_number | null_--The number of audio channels, if there is an audio track.--### `slowAudioBitrate`--_number_--The audio bitrate in bits per second. `null` if there is no audio track.--:::note-1 byte is 8 bits.-:::--### `slowVideoBitrate`--_number | null_--The video bitrate in bits per second. `null` if there is no video track.--:::note-1 byte is 8 bits.-:::--### `m3uStreams`--Only for .m3u8, this will return a non-`null` value if the file is a playlist.--An array of objects with the following fields:--- `bandwidth`: The bandwidth of the stream. May be `null`.-- `averageBandwidth`: The average bandwidth of the stream. May be `null`.-- `resolution`: The resolution of the stream. May be `null`.-- `codecs`: The codec strings of the stream as an array May be `null`.-- `url`: The URI of the stream-- `id`: A unique identifier that Remotion gives the stream-## CallbacksEach field also has a callback that allows you to retrieve the value as soon as it is obtained without waiting for the function to resolve.diff --git a/packages/docs/docs/webcodecs/convert-a-video.mdx b/packages/docs/docs/webcodecs/convert-a-video.mdxindex ab758cc7e7..e676279ba6 100644--- a/packages/docs/docs/webcodecs/convert-a-video.mdx+++ b/packages/docs/docs/webcodecs/convert-a-video.mdx@@ -26,6 +26,7 @@ The following input formats are supported:- `.mp3`- `.flac`- `.aac`+- HLS (`.m3u8`)The following output formats are supported:diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex c9214e7456..e24d215072 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -926,6 +926,7 @@ module.exports = {href: '/docs/media-parser/parse-media',label: 'API Reference',},+ 'media-parser/fields','media-parser/metadata','media-parser/fast-and-slow','media-parser/tags',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex c7d8a04baa..98ec7ea570 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -2429,6 +2429,15 @@ export const articles = [noAi: false,slug: 'media-parser/fetch-reader',},+ {+ id: 'fields',+ title: 'Available Fields',+ relativePath: 'docs/media-parser/fields.mdx',+ compId: 'articles-docs-media-parser-fields',+ crumb: '@remotion/media-parser',+ noAi: false,+ slug: 'media-parser/fields',+ },{id: 'foreign-file-types',title: 'Foreign file types',diff --git a/packages/docs/static/generated/articles-docs-media-parser-fields.png b/packages/docs/static/generated/articles-docs-media-parser-fields.pngnew file mode 100644index 0000000000..a62884a6ccBinary files /dev/null and b/packages/docs/static/generated/articles-docs-media-parser-fields.png differ