🎥 Make videos programmatically with React
Upgrade parseMedia() documentation
Jonny Burger3e1cee1b9f6d
diff --git a/packages/docs/docs/media-parser/parse-media.mdx b/packages/docs/docs/media-parser/parse-media.mdxindex ef1c72107a..df3190410e 100644--- a/packages/docs/docs/media-parser/parse-media.mdx+++ b/packages/docs/docs/media-parser/parse-media.mdx@@ -20,7 +20,7 @@ The API for getting video metadata is stable and may be used in production.import {parseMedia} from '@remotion/media-parser';const result = await parseMedia({- src: 'https://example.com/my-video.mp4',+ src: 'https://parser.media/video.mp4',fields: {durationInSeconds: true,dimensions: true,@@ -78,15 +78,19 @@ A [controller](/docs/media-parser/media-parser-controller) object that allows yo### `onVideoTrack?`A callback that is called when a video track is detected.-It receives an object with `track` and `container` (API not yet stable).+It receives an object with:++- `track` (of type [`MediaParserVideoTrack`](/docs/media-parser/types#mediaparservideotrack))+- `container` (of type [`MediaParserContainer`](/docs/media-parser/types#mediaparsercontainer))+You must return either `null` or a callback that is called for each sample that corresponds to the video track.-The `sample` has the type `VideoSample` and while not all fields are stable, it has all the mandatory fields for the [`EncodedVideoChunk`](https://developer.mozilla.org/en-US/docs/Web/API/EncodedVideoChunk) constructor.+The `sample` has the type [`MediaParserVideoSample`](/docs/media-parser/types#mediaparservideosample), which is compatible with the mandatory fields for the WebCodecs [`EncodedVideoChunk`](https://developer.mozilla.org/en-US/docs/Web/API/EncodedVideoChunk) constructor.```tsx twoslash title="Reading video frames"-import {parseMedia, OnVideoTrack} from '@remotion/media-parser';+import {parseMedia, MediaParserOnVideoTrack} from '@remotion/media-parser';-const onVideoTrack: OnVideoTrack = ({track}) => {+const onVideoTrack: MediaParserOnVideoTrack = ({track}) => {console.log(track);return (sample) => {@@ -98,16 +102,20 @@ const onVideoTrack: OnVideoTrack = ({track}) => {### `onAudioTrack?`A callback that is called when an audio track is detected.-It receives an object with `track` and `container` (API not yet stable).+It receives an object with:++- `track` (of type [`MediaParserAudioTrack`](/docs/media-parser/types#mediaparseraudiotrack))+- `container` (of type [`MediaParserContainer`](/docs/media-parser/types#mediaparsercontainer))+You must return either `null` or a callback that is called for each sample that corresponds to the audio track.-The `sample` has the type `AudioSample` and while not all fields are stable, it has all the mandatory fields for the [`EncodedAudioChunk`](https://developer.mozilla.org/en-US/docs/Web/API/EncodedAudioChunk) constructor.+The `sample` has the type [`MediaParserAudioSample`](/docs/media-parser/types#mediaparseraudiosample), which is compatible with the mandatory fields for the WebCodecs [`EncodedAudioChunk`](https://developer.mozilla.org/en-US/docs/Web/API/EncodedAudioChunk) constructor.```tsx twoslash title="Reading audio frames"// @noErrors-import {parseMedia, OnAudioTrack} from '@remotion/media-parser';+import {parseMedia, MediaParserOnAudioTrack} from '@remotion/media-parser';-const onAudioTrack: OnAudioTrack = ({track}) => {+const onAudioTrack: MediaParserOnAudioTrack = ({track}) => {console.log(track);return (sample) => {@@ -181,7 +189,7 @@ However, just like with [`fields`](#fields), adding a callback for a [slow fieldimport {parseMedia} from '@remotion/media-parser';const result = await parseMedia({- src: 'https://example.com/my-video.mp4',+ src: 'https://parser.media/video.mp4',onDurationInSeconds: (durationInSeconds) => {console.log(durationInSeconds);},