Skip to content

🎥 Make videos programmatically with React

parser.media

Jonny Burger0d7a63622664
diff --git a/packages/docs/docs/media-parser/fast-and-slow.mdx b/packages/docs/docs/media-parser/fast-and-slow.mdx
index d9a70f9c52..66610ea934 100644
--- a/packages/docs/docs/media-parser/fast-and-slow.mdx
+++ b/packages/docs/docs/media-parser/fast-and-slow.mdx
@@ -78,7 +78,7 @@ import {parseMedia} from '@remotion/media-parser';
// ---cut---
// Some fields only require the first few bytes of the file to be read:
const result = await parseMedia({
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
size: true,
container: true,
@@ -91,7 +91,7 @@ console.log(result.internalStats.finalCursorOffset); // 12
// Reading the metadata of the video will only require the metadata section to be parsed.
// You can also use onVideoTrack() and return null to retrieve track information but to not get the samples.
const result2 = await parseMedia({
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
durationInSeconds: true,
dimensions: true,
@@ -108,7 +108,7 @@ console.log(result2.dimensions);
// Asking for all video samples requires parsing the whole file
const result3 = await parseMedia({
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
internalStats: true,
},
diff --git a/packages/docs/docs/media-parser/metadata.mdx b/packages/docs/docs/media-parser/metadata.mdx
index e11f6fc634..e806e11b4c 100644
--- a/packages/docs/docs/media-parser/metadata.mdx
+++ b/packages/docs/docs/media-parser/metadata.mdx
@@ -18,7 +18,7 @@ This works in the browser as well as in Node.js and Bun.
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,
@@ -85,7 +85,7 @@ See [Available Fields](/docs/media-parser/fields) for a complete list.
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,
diff --git a/packages/docs/docs/media-parser/parse-media-on-web-worker.mdx b/packages/docs/docs/media-parser/parse-media-on-web-worker.mdx
index 25f241cd26..d5386c3ccb 100644
--- a/packages/docs/docs/media-parser/parse-media-on-web-worker.mdx
+++ b/packages/docs/docs/media-parser/parse-media-on-web-worker.mdx
@@ -23,7 +23,7 @@ The only difference in API is that the [`reader`](/docs/media-parser/parse-media
import {parseMediaOnWebWorker} from '@remotion/media-parser/worker';
const result = await parseMediaOnWebWorker({
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
durationInSeconds: true,
dimensions: true,
diff --git a/packages/docs/docs/media-parser/seeking.mdx b/packages/docs/docs/media-parser/seeking.mdx
index 28ce44c5f8..0814edef07 100644
--- a/packages/docs/docs/media-parser/seeking.mdx
+++ b/packages/docs/docs/media-parser/seeking.mdx
@@ -20,7 +20,7 @@ const controller = mediaParserController();
controller.seek(5); // Seek to 5 seconds
await parseMedia({
- src: 'https://example.com/video.mp4',
+ src: 'https://parser.media/video.mp4',
controller,
onVideoTrack: () => {
return () => {
diff --git a/packages/docs/docs/media-parser/tags.mdx b/packages/docs/docs/media-parser/tags.mdx
index e64ef68e49..3e125d6e4f 100644
--- a/packages/docs/docs/media-parser/tags.mdx
+++ b/packages/docs/docs/media-parser/tags.mdx
@@ -13,7 +13,7 @@ crumb: '@remotion/media-parser'
import {parseMedia} from '@remotion/media-parser';
const {metadata} = await parseMedia({
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
metadata: true,
},
diff --git a/packages/docs/docs/media-parser/web-reader.mdx b/packages/docs/docs/media-parser/web-reader.mdx
index aea3c2bdc6..02a9de89ac 100644
--- a/packages/docs/docs/media-parser/web-reader.mdx
+++ b/packages/docs/docs/media-parser/web-reader.mdx
@@ -23,7 +23,7 @@ import {webReader} from '@remotion/media-parser/web';
const result = await parseMedia({
// Or a `File`
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
durationInSeconds: true,
dimensions: true,
diff --git a/packages/docs/docs/media-parser/webcodecs.mdx b/packages/docs/docs/media-parser/webcodecs.mdx
index 3d99435ce2..f11be7bc7f 100644
--- a/packages/docs/docs/media-parser/webcodecs.mdx
+++ b/packages/docs/docs/media-parser/webcodecs.mdx
@@ -27,9 +27,9 @@ It is a higher-level API that is easier to use than `@remotion/media-parser`.
`@remotion/media-parser` is a lower-level API that allows you to interface with WebCodecs directly.
```tsx twoslash title="Reading video frames"
-import {parseMedia, OnAudioTrack, OnVideoTrack} from '@remotion/media-parser';
+import {parseMedia, MediaParserOnAudioTrack, MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = ({track}) => {
const videoDecoder = new VideoDecoder({
output: console.log,
error: console.error,
@@ -101,9 +101,9 @@ You can choose to not receive samples if the corresponding decoder is not suppor
```tsx twoslash title="Rejecting samples"
// @noErrors
-import type {OnAudioTrack, OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnAudioTrack, MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = ({track}) => {
if (typeof VideoDecoder === 'undefined') {
return null;
}
@@ -115,7 +115,7 @@ const onVideoTrack: OnVideoTrack = ({track}) => {
// ...
};
-const onAudioTrack: OnAudioTrack = ({track}) => {
+const onAudioTrack: MediaParserOnAudioTrack = ({track}) => {
if (typeof AudioDecoder === 'undefined') {
return null;
}
@@ -136,9 +136,9 @@ These are async APIs, fortunately `onAudioTrack` and `onVideoTrack` allow async
```tsx twoslash title="Checking if the browser supports the codec"
// @noErrors
-import type {OnAudioTrack, OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnAudioTrack, MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = async ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {
const videoDecoder = new VideoDecoder({
output: console.log,
error: console.error,
@@ -152,7 +152,7 @@ const onVideoTrack: OnVideoTrack = async ({track}) => {
// ...
};
-const onAudioTrack: OnAudioTrack = async ({track}) => {
+const onAudioTrack: MediaParserOnAudioTrack = async ({track}) => {
const audioDecoder = new AudioDecoder({
output: console.log,
error: console.error,
@@ -179,9 +179,9 @@ The decoder `state` will switch to `"closed"`, however, you will still receive s
If the decoder is in `"closed"` state, you should stop passing them to VideoDecoder.
```tsx twoslash title="Error handling"
-import type {OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = async ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {
const videoDecoder = new VideoDecoder({
output: console.log,
error: console.error,
@@ -212,9 +212,9 @@ For this, make the sample processing function async. Remotion will await it befo
This will make it so that samples that are not yet needed are not kept in memory, keeping the decoding process efficient.
```tsx twoslash title="Only keeping 10 samples in the queue at a time"
-import type {OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = async ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {
const videoDecoder = new VideoDecoder({
output: console.log,
error: console.error,
@@ -252,9 +252,9 @@ Some videos don't have the same dimensions internally as they are presented.
For example, [this sample video](https://github.com/remotion-dev/remotion/blob/main/packages/example/public/stretched-vp8.webm) has a coded width of 1440, but a presentation width of 1920.
```tsx twoslash title="Handling stretched videos"
-import type {OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = async ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {
const videoDecoder = new VideoDecoder({
output: console.log,
error: console.error,
@@ -286,9 +286,9 @@ For example, this [video recorded with an iPhone](https://github.com/remotion-de
Fortunately `parseMedia()` returns the rotation of the track:
```tsx twoslash title="Handling stretched videos"
-import type {OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = async ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {
console.log(track.rotation); // -90
return null;
};
@@ -302,9 +302,9 @@ As just mentioned, some videos might be stretched or rotated.
In an extreme case, it is possible that you stumble opon a video that has three different dimensions.
```tsx twoslash title="Handling stretched videos"
-import type {OnVideoTrack} from '@remotion/media-parser';
+import type {MediaParserOnVideoTrack} from '@remotion/media-parser';
-const onVideoTrack: OnVideoTrack = async ({track}) => {
+const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {
console.log(track);
// {
// codedWidth: 1440,
diff --git a/packages/docs/docs/media-parser/workers.mdx b/packages/docs/docs/media-parser/workers.mdx
index fb6945a2de..033c578c46 100644
--- a/packages/docs/docs/media-parser/workers.mdx
+++ b/packages/docs/docs/media-parser/workers.mdx
@@ -24,7 +24,7 @@ The API takes care of exchanging messages between the main thread and the Web Wo
import {parseMediaOnWebWorker} from '@remotion/media-parser/worker';
const result = await parseMediaOnWebWorker({
- src: 'https://example.com/my-video.mp4',
+ src: 'https://parser.media/video.mp4',
fields: {
durationInSeconds: true,
dimensions: true,