🎥 Make videos programmatically with React
new API
Jonny Burger6dbf357cbc2a
diff --git a/packages/docs/components/TableOfContents/api.tsx b/packages/docs/components/TableOfContents/api.tsxindex 4a3095518f..13183e0c44 100644--- a/packages/docs/components/TableOfContents/api.tsx+++ b/packages/docs/components/TableOfContents/api.tsx@@ -15,8 +15,8 @@ import {TableOfContents as LicensingTableOfContents} from '../../docs/licensing/import {TableOfContents as LottieTableOfContents} from '../../docs/lottie/table-of-contents';import {TableOfContents as MediaParserTableOfContents} from '../../docs/media-parser/TableOfContents';import {TableOfContents as MediaUtilsTableOfContents} from '../../docs/media-utils/table-of-contents';+import {TableOfContents as NewVideoTableOfContents} from '../../docs/media/table-of-contents';import {TableOfContents as MotionBlurTableOfContents} from '../../docs/motion-blur/table-of-contents';-import {TableOfContents as NewVideoTableOfContents} from '../../docs/new-video/table-of-contents';import {TableOfContents as NoiseTableOfContents} from '../../docs/noise/table-of-contents';import {TableOfContents as OpenAiWhisperTableOfContents} from '../../docs/openai-whisper/TableOfContents';import {TableOfContents as PathsTableOfContents} from '../../docs/paths/table-of-contents';diff --git a/packages/docs/docs/audio.mdx b/packages/docs/docs/audio.mdxindex f90341bbd3..7935f388f5 100644--- a/packages/docs/docs/audio.mdx+++ b/packages/docs/docs/audio.mdx@@ -2,7 +2,7 @@image: /generated/articles-docs-audio.pngtitle: <Audio>id: audio-crumb: 'How to'+crumb: 'API - remotion'---Using this component, you can add audio to your video. All audio formats which are supported by Chromium are supported by the component.@@ -191,7 +191,6 @@ Multiple audio streams can be used for example for adding multiple languages toAudio streams are zero-indexed.:::-### `acceptableTimeShiftInSeconds?`<AvailableFrom v="3.2.42"/>In the [Remotion Studio](/docs/terminology/studio) or in the [Remotion Player](/docs/player), Remotion will seek the audio if it gets too much out of sync with Remotion's internal time - be it due to the audio loading or the page being too slow to keep up in real-time. By default, a seek is triggered if `0.45` seconds of time shift is encountered. Using this prop, you can customize the threshold.@@ -233,6 +232,7 @@ To prevent synthetic amplification, set a volume not higher than 1.- [Using audio](/docs/using-audio)- [Audio visualization](/docs/audio/visualization)- [`<Video />`](/docs/video)+- [`<Audio />` (from `@remotion/media`)](/docs/media/audio)<Creditscontributors={[diff --git a/packages/docs/docs/media/audio.mdx b/packages/docs/docs/media/audio.mdxnew file mode 100644index 0000000000..3122c81f7e--- /dev/null+++ b/packages/docs/docs/media/audio.mdx@@ -0,0 +1,157 @@+---+image: /generated/articles-docs-media-audio.png+title: '<Audio>'+crumb: 'API - @remotion/media'+---++:::warning+**Very experimental**: This component is in a very early stage and does not support some basic features such as volume or playback rate.+The current focus is on correctness, not on performance.++We recommend that you use [`<Audio />`](/docs/audio) for now.+:::++This component imports and displays a video, similar to [`<Audio />`](/docs/audio) from `remotion` but during rendering, extracts the exact audio using [Mediabunny](/docs/mediabunny) instead of FFmpeg.++## Example++```tsx twoslash+import {AbsoluteFill, staticFile} from 'remotion';+import {experimental_Audio as Audio} from '@remotion/media';++export const MyVideo = () => {+ return (+ <AbsoluteFill>+ <Audio src={staticFile('audio.mp3')} />+ </AbsoluteFill>+ );+};+```++You can load a video from an URL as well:++```tsx twoslash+import {AbsoluteFill} from 'remotion';+import {experimental_Audio as Audio} from '@remotion/media';+// ---cut---+export const MyComposition = () => {+ return (+ <AbsoluteFill>+ <Audio src="https://parser.media/audio.wav" />+ </AbsoluteFill>+ );+};+```++## Props++### `src`++The URL of the audio to be rendered. Can be a remote URL or a local file referenced with [`staticFile()`](/docs/staticfile).++### `trimBefore?`++Will remove a portion of the audio at the beginning (left side).++In the following example, we assume that the [`fps`](/docs/composition#fps) of the composition is `30`.++By passing `trimBefore={60}`, the playback starts immediately, but with the first 2 seconds of the audio trimmed away.+By passing `trimAfter={120}`, any audio after the 4 second mark in the file will be trimmed away.++The audio will play the range from `00:02:00` to `00:04:00`, meaning the audio will play for 2 seconds.++For exact behavior, see: [Order of operations](/docs/audio/order-of-operations).++```tsx twoslash+import {AbsoluteFill, staticFile} from 'remotion';+import {experimental_Audio as Audio} from '@remotion/media';++// ---cut---+export const MyComposition = () => {+ return (+ <AbsoluteFill>+ <Audio src={staticFile('audio.mp3')} trimBefore={60} trimAfter={120} />+ </AbsoluteFill>+ );+};+```++### `trimAfter?`++Removes a portion of the audio at the end (right side). See [`trimBefore`](#trimbefore) for an explanation.++### `volume?`++**Currently not supported!**++### `loopVolumeCurveBehavior?`++**Currently not supported!**++### `name?`++A name and that will be shown as the label of the sequence in the timeline of the Remotion Studio. This property is purely for helping you keep track of items in the timeline.++### `onError?`++**Currently not supported!**++### `playbackRate?`++**Currently not supported!**++### `muted?`++The `muted` prop will be respected. It will lead to no audio being played while still keeping the audio tag mounted. It's value may change over time, for example to only mute a certain section of the audio.++```tsx twoslash title="Example of a muted video"+import {AbsoluteFill, OffthreadVideo} from 'remotion';+import {experimental_Audio as Audio} from '@remotion/media';+// ---cut---+export const MyComposition = () => {+ return (+ <AbsoluteFill>+ <Audio muted src="https://parser.media/audio.wav" />+ </AbsoluteFill>+ );+};+```++### `acceptableTimeShiftInSeconds?`++**Pending removal**: Future iterations will also have client-side playback and not support this prop which was designed for the `<audio>` tag.++### `pauseWhenBuffering?`++If set to `true` and the audio is loading, the Player will enter into the [native buffering state](/docs/player/buffer-state). The default is `false`, but will become `true` in Remotion 5.0.++### `showInTimeline?`++If set to `false`, no layer will be shown in the timeline of the Remotion Studio. The default is `true`.++### `delayRenderTimeoutInMilliseconds?`++Customize the [timeout](/docs/delay-render#modifying-the-timeout) of the [`delayRender()`](/docs/delay-render) call that this component makes.++### `delayRenderRetries?`++Customize the [number of retries](/docs/delay-render#retrying) of the [`delayRender()`](/docs/delay-render) call that this component makes.++### `onAutoPlayError?`++**Pending removal**: Future iterations will also have client-side playback and not support this prop which was designed for the `<audio>` tag.++### `crossOrigin?`++**Pending removal**: Future iterations will also have client-side playback and not support this prop which was designed for the `<audio>` tag.++### `useWebAudioApi?`++**Pending removal**: Future iterations will also have client-side playback and not support this prop which was designed for the `<audio>` tag.++## See also++- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/media/src/audio/audio.tsx)+- [`<Audio />` (from `remotion`)](/docs/audio)+- [`<Video />` (from `@remotion/media`)](/docs/media/video)+- [`<OffthreadVideo>`](/docs/offthreadvideo)diff --git a/packages/docs/docs/media/table-of-contents.tsx b/packages/docs/docs/media/table-of-contents.tsxnew file mode 100644index 0000000000..971da85c49--- /dev/null+++ b/packages/docs/docs/media/table-of-contents.tsx@@ -0,0 +1,24 @@+import React from 'react';+import {Grid} from '../../components/TableOfContents/Grid';+import {TOCItem} from '../../components/TableOfContents/TOCItem';++export const TableOfContents: React.FC = () => {+ return (+ <div>+ <Grid>+ <TOCItem link="/docs/media/video">+ <strong>{'<Viewo>'}</strong>+ <div>+ WebCodecs-based video tag for efficient and accurate embedding+ </div>+ </TOCItem>+ <TOCItem link="/docs/media/audio">+ <strong>{'<Audio>'}</strong>+ <div>+ WebCodecs-based audio tag for efficient and accurate embedding+ </div>+ </TOCItem>+ </Grid>+ </div>+ );+};diff --git a/packages/docs/docs/new-video/index.mdx b/packages/docs/docs/media/video.mdxsimilarity index 92%rename from packages/docs/docs/new-video/index.mdxrename to packages/docs/docs/media/video.mdxindex 7e49414695..0309ba3541 100644--- a/packages/docs/docs/new-video/index.mdx+++ b/packages/docs/docs/media/video.mdx@@ -1,14 +1,14 @@----image: /generated/articles-docs-new-video-index.png-title: '<NewVideo>'-crumb: 'API'+image: /generated/articles-docs-media-video.png+title: '<Video>'+crumb: 'API - @remotion/media'---:::warning**Very experimental**: This component is in a very early stage and does not support some basic features such as volume or playback rate or CSS styling.The current focus is on correctness, not on performance.-We recommend that you use [`<OffthreadVideo/>`](/docs/offthreadvideo) for now.+We recommend that you use [`<OffthreadVideo />`](/docs/offthreadvideo) for now.:::This component imports and displays a video, similar to [`<OffthreadVideo/>`](/docs/offthreadvideo) but during rendering, extracts the exact frame from the video using [Mediabunny](/docs/mediabunny) and displays it in a `<canvas>` tag.@@ -78,7 +78,7 @@ export const MyComposition = () => {### `trimAfter?`-Removes a portion of the video at the end (right side). See [`trimBefore`](/docs/video#trimbefore) for an explanation.+Removes a portion of the video at the end (right side). See [`trimBefore`](#trimbefore) for an explanation.### `volume?`@@ -147,16 +147,17 @@ A callback function that gets called when a frame is extracted from the video.Useful for [video manipulation](/docs/video-manipulation).The callback is called with a [`CanvasImageSource`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource) object, more specifically, either an `ImageBitmap` or a `VideoFrame`.-### `crossOrigin?`<AvailableFrom v="4.0.190" />+### `crossOrigin?`**Pending removal**: Future iterations will also have client-side playback and not support this prop which was designed for the `<video>` tag.-### `useWebAudioApi?`<AvailableFrom v="4.0.306" />+### `useWebAudioApi?`**Pending removal**: Future iterations will also have client-side playback and not support this prop which was designed for the `<video>` tag.## See also-- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/video/src/new-video.tsx)-- [`<Video />`](/docs/video)+- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/media/src/video/video.tsx)+- [`<Audio />` (from `@remotion/media`)](/docs/media/audio)+- [`<Video />` (from `remotion`)](/docs/video)- [`<OffthreadVideo>`](/docs/offthreadvideo)diff --git a/packages/docs/docs/new-video/table-of-contents.tsx b/packages/docs/docs/new-video/table-of-contents.tsxdeleted file mode 100644index 6d568819d4..0000000000--- a/packages/docs/docs/new-video/table-of-contents.tsx+++ /dev/null@@ -1,16 +0,0 @@-import React from 'react';-import {Grid} from '../../components/TableOfContents/Grid';-import {TOCItem} from '../../components/TableOfContents/TOCItem';--export const TableOfContents: React.FC = () => {- return (- <div>- <Grid>- <TOCItem link="/docs/video">- <strong>{'<NewVideo>'}</strong>- <div>Tag for reliable and accurate video embedding</div>- </TOCItem>- </Grid>- </div>- );-};diff --git a/packages/docs/docs/video.mdx b/packages/docs/docs/video.mdxindex 4e2dcc8dbd..b7d9f5fe06 100644--- a/packages/docs/docs/video.mdx+++ b/packages/docs/docs/video.mdx@@ -2,7 +2,7 @@image: /generated/articles-docs-video.pngtitle: <Video>id: video-crumb: 'API'+crumb: 'API - remotion'---Wraps the native [`<video>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement) element to include video in your component that is synchronized with Remotion's time.@@ -247,7 +247,6 @@ Multiple audio streams can be used for example for adding multiple languages toAudio streams are zero-indexed.:::-### `onError?`Handle an error playing the video. From v3.3.89, if you pass an `onError` callback, then no exception will be thrown. Previously, the error could not be caught.@@ -310,4 +309,5 @@ See: [Which video formats does Remotion support?](/docs/miscellaneous/video-form- [`<Audio />`](/docs/audio)- [`<OffthreadVideo />`](/docs/offthreadvideo)- [`<Video>` vs `<OffthreadVideo>`](/docs/video-vs-offthreadvideo)+- [`<Video />` (from `@remotion/media`)](/docs/media/video)- [`Change the speed of a video over time`](/docs/miscellaneous/snippets/accelerated-video)diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex 1113842308..6baaabfc58 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -781,9 +781,9 @@ const sidebars: SidebarsConfig = {label: '@remotion/media',link: {type: 'doc',- id: 'new-video/index',+ id: 'media/video',},- items: ['new-video/index'],+ items: ['media/audio', 'media/video'],},],mainSidebar: [diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex f6579d18a7..7f3ca0e4aa 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -256,7 +256,7 @@ export const articles = [title: '<Audio>',relativePath: 'docs/audio.mdx',compId: 'articles-docs-audio',- crumb: 'How to',+ crumb: 'API - remotion',noAi: false,slug: 'audio',},@@ -3275,6 +3275,24 @@ export const articles = [noAi: false,slug: 'media-utils/visualize-audio-waveform',},+ {+ id: 'media/audio',+ title: '<Audio>',+ relativePath: 'docs/media/audio.mdx',+ compId: 'articles-docs-media-audio',+ crumb: 'API - @remotion/media',+ noAi: false,+ slug: 'media/audio',+ },+ {+ id: 'media/video',+ title: '<Video>',+ relativePath: 'docs/media/video.mdx',+ compId: 'articles-docs-media-video',+ crumb: 'API - @remotion/media',+ noAi: false,+ slug: 'media/video',+ },{id: 'mediabunny',title: 'Remotion and Mediabunny',@@ -3612,15 +3630,6 @@ export const articles = [noAi: false,slug: 'multiple-fps',},- {- id: 'new-video/index',- title: '<NewVideo>',- relativePath: 'docs/new-video/index.mdx',- compId: 'articles-docs-new-video-index',- crumb: 'API',- noAi: false,- slug: 'new-video/index',- },{id: 'noise-visualization',title: 'Noise visualization',@@ -6176,7 +6185,7 @@ export const articles = [title: '<Video>',relativePath: 'docs/video.mdx',compId: 'articles-docs-video',- crumb: 'API',+ crumb: 'API - remotion',noAi: false,slug: 'video',},diff --git a/packages/docs/static/generated/articles-docs-media-audio.png b/packages/docs/static/generated/articles-docs-media-audio.pngnew file mode 100644index 0000000000..d00e35e510Binary files /dev/null and b/packages/docs/static/generated/articles-docs-media-audio.png differdiff --git a/packages/docs/static/generated/articles-docs-media-video.png b/packages/docs/static/generated/articles-docs-media-video.pngnew file mode 100644index 0000000000..7b051de811Binary files /dev/null and b/packages/docs/static/generated/articles-docs-media-video.png differdiff --git a/packages/docs/static/generated/articles-docs-new-video-index.png b/packages/docs/static/generated/articles-docs-new-video-index.pngdeleted file mode 100644index 2d15f887c3..0000000000Binary files a/packages/docs/static/generated/articles-docs-new-video-index.png and /dev/null differ