🎥 Make videos programmatically with React
Docs: Recommend @remotion/media tags (#8899)
Jonny Burgerdddd158108d7
diff --git a/packages/docs/docs/importing-assets.mdx b/packages/docs/docs/importing-assets.mdxindex 842b50a09e..59ea1712b1 100644--- a/packages/docs/docs/importing-assets.mdx+++ b/packages/docs/docs/importing-assets.mdx@@ -75,23 +75,26 @@ const MyComp: React.FC = () => {## Using videos-Use the [`<OffthreadVideo />`](/docs/offthreadvideo), [`<Video />`](/docs/media/video) or [`<Html5Video />`](/docs/html5-video) component to keep the timeline and your video in sync.+Use the [`<Video />` from `@remotion/media`](/docs/media/video) component to keep the timeline and your video in sync.++[`<OffthreadVideo />`](/docs/offthreadvideo) and [`<Html5Video />`](/docs/html5-video) are legacy alternatives.```tsx twoslash-import {OffthreadVideo, staticFile} from 'remotion';+import {Video} from '@remotion/media';+import {staticFile} from 'remotion';export const MyComp: React.FC = () => {- return <OffthreadVideo src={staticFile('vid.webm')} />;+ return <Video src={staticFile('vid.webm')} />;};```Loading videos via URL is also possible:```tsx twoslash-import {OffthreadVideo} from 'remotion';+import {Video} from '@remotion/media';export const MyComp: React.FC = () => {- return <OffthreadVideo src="https://remotion.media/BigBuckBunny.mp4" />;+ return <Video src="https://remotion.media/BigBuckBunny.mp4" />;};```@@ -99,23 +102,24 @@ See also: [Which video formats does Remotion support?](/docs/miscellaneous/video## Using Audio-Use the [`<Html5Audio>`](/docs/html5-audio) component.+Use the [`<Audio>` from `@remotion/media`](/docs/media/audio) component.```tsx twoslash-import {Html5Audio, staticFile} from 'remotion';+import {Audio} from '@remotion/media';+import {staticFile} from 'remotion';export const MyComp: React.FC = () => {- return <Html5Audio src={staticFile('tune.mp3')} />;+ return <Audio src={staticFile('tune.mp3')} />;};```Loading audio from an URL is also possible:```tsx twoslash-import {Html5Audio} from 'remotion';+import {Audio} from '@remotion/media';export const MyComp: React.FC = () => {- return <Html5Audio src="https://file-examples.com/storage/fe48a63c5264cbd519788b3/2017/11/file_example_MP3_700KB.mp3" />;+ return <Audio src="https://file-examples.com/storage/fe48a63c5264cbd519788b3/2017/11/file_example_MP3_700KB.mp3" />;};```@@ -199,7 +203,7 @@ However, if you use the [server-side rendering APIs](/docs/ssr-node), you can ad## Use `<Img>`, `<Video>` and `<Audio>`**Use [`<Img />`](/docs/img) or [`<Gif />`](/docs/gif)** over the native `<img>` tag, `<Image>` from Next.js and CSS `background-image`.-**Use [`<OffthreadVideo />`](/docs/offthreadvideo), [`<Video />`](/docs/media/video) or [`<Html5Video />`](/docs/html5-video)** over the native `<video>` tag.+**Use [`<Video />` from `@remotion/media`](/docs/media/video), [`<OffthreadVideo />`](/docs/offthreadvideo) or [`<Html5Video />`](/docs/html5-video)** over the native `<video>` tag.**Use [`<Audio />`](/docs/media/audio) or [`<Html5Audio />`](/docs/html5-audio)** over the native `<audio>` tag.**Use [`<IFrame />`](/docs/iframe)** over the native `<iframe>` tag.diff --git a/packages/docs/docs/lambda/troubleshooting/chrome-133-situation.mdx b/packages/docs/docs/lambda/troubleshooting/chrome-133-situation.mdxdeleted file mode 100644index 1a1a30693e..0000000000--- a/packages/docs/docs/lambda/troubleshooting/chrome-133-situation.mdx+++ /dev/null@@ -1,36 +0,0 @@-----image: /generated/articles-docs-lambda-troubleshooting-chrome-133-situation.png-id: chrome-133-situation-title: 'Chrome 133 situation'-sidebar_label: Chrome 133 situation-crumb: 'Lambda'------:::note-Resolved in Remotion version v4.0.289.-:::--From Remotion version v4.0.274 - v4.0.288, there has been an inadvertent change that breaks some workflows on Lambda that expect Chrome to have been compiled proprietary video codecs.--## When you are affected--You are affected if you:--- are on Remotion version 4.0.274 - 4.0.288 (inclusive)-- are using Remotion Lambda-- are using the [getVideoMetadata()](/docs/get-video-metadata) API from [@remotion/media-utils](/docs/media-utils) or the `<Html5Video>` tag with an MP4 file--## Solution--Upgrade to Remotion version v4.0.289 or higher.--## Workarounds--- Option 1: Revert to Remotion version 4.0.273-- Option 2: Replace [getVideoMetadata()](/docs/renderer/get-video-metadata) with [parseMedia()](/docs/media-parser/parse-media) and `<Html5Video>` with `<OffthreadVideo>` if you can. We recommend both of these in general.--## Apologies--We are sorry for this oversight from our side and the troubles it may cause.--We’ll add tests to Remotion Lambda to ensure this issue cannot happen in the future.diff --git a/packages/docs/docs/media/audio.mdx b/packages/docs/docs/media/audio.mdxindex 711b218042..54ba89fb03 100644--- a/packages/docs/docs/media/audio.mdx+++ b/packages/docs/docs/media/audio.mdx@@ -4,12 +4,9 @@ title: '<Audio>'crumb: 'API - @remotion/media'----:::note-This is documentation for the new `<Audio>` tag.-Not to be confused with the older [`<Html5Audio>` / `<Audio>`](/docs/html5-audio) tag from `remotion`.-:::+[`<Audio>` from `@remotion/media`](/docs/media/audio) is the recommended component for embedding audio in Remotion.-This component imports and plays audio, similar to [`<Html5Audio />`](/docs/html5-audio) from `remotion` but during rendering, extracts the exact audio using [Mediabunny](/docs/mediabunny) instead of FFmpeg.+During rendering, it extracts the exact audio using [Mediabunny](/docs/mediabunny) instead of FFmpeg. This keeps the audio in sync with Remotion's timeline.## Examplediff --git a/packages/docs/docs/media/index.mdx b/packages/docs/docs/media/index.mdxindex 3f400867cb..5f71dc1b55 100644--- a/packages/docs/docs/media/index.mdx+++ b/packages/docs/docs/media/index.mdx@@ -8,7 +8,9 @@ import {TableOfContents} from './table-of-contents';# @remotion/media-A package providing utility functions for getting information about video and audio, and for visualizing audio.+This package provides the recommended [`<Video>`](/docs/media/video) and [`<Audio>`](/docs/media/audio) tags for embedding video and audio in Remotion.++Use these tags for new projects instead of the legacy media tags from the [`remotion`](/docs/remotion) package.## Componentsdiff --git a/packages/docs/docs/media/video.mdx b/packages/docs/docs/media/video.mdxindex 03f0fc54cc..500f541cdf 100644--- a/packages/docs/docs/media/video.mdx+++ b/packages/docs/docs/media/video.mdx@@ -4,12 +4,9 @@ title: '<Video>'crumb: 'API - @remotion/media'----:::note-This is documentation for the new `<Video>` tag.-Not to be confused with the older [`<Html5Video>` / `<Video>`](/docs/html5-video) tag from `remotion`.-:::+[`<Video>` from `@remotion/media`](/docs/media/video) is the recommended component for embedding videos in Remotion.-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.+During rendering, it extracts the exact frame from the video using [Mediabunny](/docs/mediabunny) and displays it in a `<canvas>` tag. This keeps the video in sync with Remotion's timeline.This component has [native buffering support](/docs/player/buffer-state) enabled by default. When used in the Player, it automatically pauses playback when buffering and resumes when ready.@@ -270,11 +267,7 @@ import {Video} from '@remotion/media';export const MyComposition = () => {return (<AbsoluteFill>- <Video- src={staticFile('video.webm')}- style={{width: '100%', height: '100%'}}- objectFit="cover"- />+ <Video src={staticFile('video.webm')} style={{width: '100%', height: '100%'}} objectFit="cover" /></AbsoluteFill>);};diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdxindex c23de8c7a8..683b8b1960 100644--- a/packages/docs/docs/offthreadvideo.mdx+++ b/packages/docs/docs/offthreadvideo.mdx@@ -5,7 +5,7 @@ title: '<OffthreadVideo>'crumb: 'API'----<AvailableFrom v="3.0.11" />+# <OffthreadVideo><AvailableFrom v="3.0.11" />This component imports and displays a video, similar to [`<Html5Video/>`](/docs/html5-video), but during rendering, extracts the exact frame from the video and displays it in a [`<Img>`](/docs/img) tag. This extraction process happens outside the browser using FFmpeg.diff --git a/packages/docs/docs/player/preloading.mdx b/packages/docs/docs/player/preloading.mdxindex 5a4b3277cd..7abe7d7437 100644--- a/packages/docs/docs/player/preloading.mdx+++ b/packages/docs/docs/player/preloading.mdx@@ -32,8 +32,12 @@ unpreloadAudio();_Available in v3.2.23_+:::note+Prefetch is not recommended for most cases. [See recommendations](/docs/troubleshooting/player-flicker#strategies).+:::+By prefetching, the full media is downloaded and turned into a Blob URL using [`URL.createObjectURL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL).-If you pass the original URL into either an [`<Audio>`](/docs/media/audio), [`<Video>`](/docs/media/video), [`<OffthreadVideo>`](/docs/offthreadvideo), [`<Html5Audio>`](/docs/html5-audio), [`<Html5Video>`](/docs/html5-video), or [`<Img>`](/docs/img) tag and the asset is prefetched, those components will use Blob URL instead.+If you pass the original URL into either an [`<Video>`](/docs/media/video), [`<Audio>`](/docs/media/audio), [`<Html5Audio>`](/docs/html5-audio), [`<Html5Video>`](/docs/html5-video), [`<OffthreadVideo>`](/docs/offthreadvideo), or [`<Img>`](/docs/img) tag and the asset is prefetched, those components will use Blob URL instead.```tsx twoslashimport {prefetch} from 'remotion';@@ -62,6 +66,10 @@ free();<code>preloadAudio()</code><br /><code>preloadVideo()</code>+ <br />+ <code>preloadImage()</code>+ <br />+ <code>preloadFont()</code></div></th><th>@@ -72,31 +80,19 @@ free();</tr><tr><td>Works with</td>- <td>All audio and video APIs, images and fonts</td>+ <td>HTML5 audio/video tags, images and fonts</td><td>- <a href="/docs/media/audio">- <code>{'<Audio/>'}</code>- </a>- ,{' '}<a href="/docs/media/video"><code>{'<Video/>'}</code></a>,{' '}- <a href="/docs/html5-audio">- <code>{'<Html5Audio/>'}</code>- </a>- ,{' '}- <a href="/docs/html5-video">- <code>{'<Html5Video/>'}</code>+ <a href="/docs/media/audio">+ <code>{'<Audio/>'}</code></a>- ,{' '}+ , legacy media tags and{' '}<a href="/docs/img"><code>{'<Img/>'}</code></a>- ,{' '}- <a href="/docs/offthreadvideo">- <code>{'<OffthreadVideo/>'}</code>- </a></td></tr><tr>diff --git a/packages/docs/docs/prefetch.mdx b/packages/docs/docs/prefetch.mdxindex c4e3b0621c..69422416fe 100644--- a/packages/docs/docs/prefetch.mdx+++ b/packages/docs/docs/prefetch.mdx@@ -7,9 +7,13 @@ crumb: 'API'_Available in v3.2.23_+:::note+Prefetch is not recommended for most cases. [See recommendations](/docs/troubleshooting/player-flicker#strategies).+:::+By calling `prefetch()`, an asset will be fetched and kept in memory so it is ready when you want to play it in a [`<Player>`](/docs/player).-If you pass the original URL into either an [`<Html5Audio>`](/docs/html5-audio), [`<Audio>`](/docs/media/audio), [`<Video>`](/docs/media/video), [`<Html5Video>`](/docs/html5-video), [`<OffthreadVideo>`](/docs/offthreadvideo) or [`<Img>`](/docs/img) tag and the asset is fully fetched, those components will use Blob URL instead.+If you pass the original URL into either a [`<Video>`](/docs/media/video), [`<Audio>`](/docs/media/audio), [`<Html5Audio>`](/docs/html5-audio), [`<Html5Video>`](/docs/html5-video), [`<OffthreadVideo>`](/docs/offthreadvideo) or [`<Img>`](/docs/img) tag and the asset is fully fetched, those components will use Blob URL instead.:::noteRemote assets need to support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).diff --git a/packages/docs/docs/timeout.mdx b/packages/docs/docs/timeout.mdxindex d850882606..fd9e8c6564 100644--- a/packages/docs/docs/timeout.mdx+++ b/packages/docs/docs/timeout.mdx@@ -45,7 +45,9 @@ Especially 1.x releases could timeout when importing large assets### Video needs to be downloaded-If you render a video using [`<OffthreadVideo>`](/docs/offthreadvideo), then the video needs to be downloaded before it can be read. [If the video is large and takes longer than the timeout to be downloaded, then the timeout will be triggered](/docs/troubleshooting/delay-render-proxy). In that you should increase the [timeout](#increase-timeout).+If you render a video using [`<OffthreadVideo>`](/docs/offthreadvideo), then the video needs to be downloaded before it can be read. [If the video is large and takes longer than the timeout to be downloaded, then the timeout will be triggered](/docs/troubleshooting/delay-render-proxy). In that case, increase the [timeout](#increase-timeout).++[`<Video>` from `@remotion/media`](/docs/media/video) does not have this limitation and is preferred for new projects.### Not helpful?diff --git a/packages/docs/docs/transparent-videos.mdx b/packages/docs/docs/transparent-videos.mdxindex 346c43e181..5c85230afe 100644--- a/packages/docs/docs/transparent-videos.mdx+++ b/packages/docs/docs/transparent-videos.mdx@@ -148,6 +148,12 @@ By default, the [`<OffthreadVideo>`](/docs/offthreadvideo) does not add an alphaAdd the [`transparent`](/docs/offthreadvideo#transparent) prop to flag that the video has an alpha channel.This slightly reduces the performance of the render.+## Transparency when using `<Video>`++[`<Video>` from `@remotion/media`](/docs/media/video) is recommended for embedding transparent videos.++No `transparent` prop is needed when the video is decoded by [`@remotion/media`](/docs/media). If it falls back to [`<OffthreadVideo>`](/docs/media/fallback), transparency is enabled on the fallback by default.+## Creating a fallback versionGiven the poor browser support, consider making two versions of a video, one with alpha channel, and an opaque video as a fallback. You can achieve this in Remotion using standard React props:diff --git a/packages/docs/docs/troubleshooting/no-frame-found-at-position.mdx b/packages/docs/docs/troubleshooting/no-frame-found-at-position.mdxindex 6df194664b..6577c78b8b 100644--- a/packages/docs/docs/troubleshooting/no-frame-found-at-position.mdx+++ b/packages/docs/docs/troubleshooting/no-frame-found-at-position.mdx@@ -28,3 +28,9 @@ For example, a screen recording that does not have any movement for a few secondOffthreadVideo currently struggles with these types of videos as the closest frame has too much of a deviation from the requested time.In this case, we recommend to consult with the Remotion team by filing an issue on [GitHub](https://remotion.dev/issue) and submitting the [video](https://remotion.dev/report).++## Use `<Video>` from `@remotion/media`++For new projects, [`<Video>` from `@remotion/media`](/docs/media/video) is now recommended over [`<OffthreadVideo>`](/docs/offthreadvideo).++See the [comparison of video tags](/docs/video-tags) for the differences between the available video components.diff --git a/packages/docs/docs/troubleshooting/video-has-no-sound.mdx b/packages/docs/docs/troubleshooting/video-has-no-sound.mdxindex 0225849095..82f3e0d24d 100644--- a/packages/docs/docs/troubleshooting/video-has-no-sound.mdx+++ b/packages/docs/docs/troubleshooting/video-has-no-sound.mdx@@ -2,7 +2,7 @@image: /generated/articles-docs-troubleshooting-video-has-no-sound.pngsidebar_label: Video has no soundtitle: Why does my video not have sound?-crumb: "Troubleshooting"+crumb: 'Troubleshooting'---If you rendered a video with Remotion and it appears to have no audio, the most common cause is that you are playing it back in an editor that mutes video by default.@@ -25,7 +25,7 @@ If the video still has no sound after opening it in a media player:### No audio source in the composition-Make sure your Remotion composition includes an audio source. You can add audio using [`<Audio>`](/docs/using-audio), or extract audio from a video using [`<Html5Video>`](/docs/html5-video) or [`<OffthreadVideo>`](/docs/offthreadvideo).+Make sure your Remotion composition includes an audio source. You can add audio using [`<Audio>`](/docs/media/audio), or include the audio track of a video using [`<Video>`](/docs/media/video), both from [`@remotion/media`](/docs/media).### Audio volume set to 0diff --git a/packages/docs/docs/use-img-and-iframe.mdx b/packages/docs/docs/use-img-and-iframe.mdxindex ed18c50b91..6e37edfd2c 100644--- a/packages/docs/docs/use-img-and-iframe.mdx+++ b/packages/docs/docs/use-img-and-iframe.mdx@@ -6,7 +6,7 @@ crumb: 'Best practices'---**Use [`<Img />`](/docs/img) or [`<Gif />`](/docs/gif)** over the native `<img>` tag, `<Image>` from Next.js and CSS `background-image`.-**Use [`<OffthreadVideo />`](/docs/offthreadvideo), [`<Video />`](/docs/media/video) or [`<Html5Video />`](/docs/html5-video)** over the native `<video>` tag.+**Use [`<Video />`](/docs/media/video), [`<OffthreadVideo />`](/docs/offthreadvideo) or [`<Html5Video />`](/docs/html5-video)** over the native `<video>` tag.**Use [`<Audio />`](/docs/media/audio) or [`<Html5Audio />`](/docs/html5-audio)** over the native `<audio>` tag.**Use [`<IFrame />`](/docs/iframe)** over the native `<iframe>` tag.diff --git a/packages/docs/docs/use-remotion-environment.mdx b/packages/docs/docs/use-remotion-environment.mdxindex 41f5e6254a..57596948fc 100644--- a/packages/docs/docs/use-remotion-environment.mdx+++ b/packages/docs/docs/use-remotion-environment.mdx@@ -57,6 +57,6 @@ The hook helps to scope the environment information to the context of component## See also- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/core/src/use-remotion-environment.ts)-- [getRemotionEnvironment()](/docs/get-remotion-environment)-- [useVideoConfig()](/docs/use-video-config)-- [`<OffthreadVideo/> while rendering`](/docs/video-tags#using-a-different-tag-in-preview-and-rendering)+- [`getRemotionEnvironment()`](/docs/get-remotion-environment)+- [`useVideoConfig()`](/docs/use-video-config)+- [Using a different tag in preview and rendering](/docs/video-tags#using-a-different-tag-in-preview-and-rendering)diff --git a/packages/docs/docs/using-audio.mdx b/packages/docs/docs/using-audio.mdxindex 5b7b73c95a..f0fce5d870 100644--- a/packages/docs/docs/using-audio.mdx+++ b/packages/docs/docs/using-audio.mdx@@ -19,4 +19,5 @@ import {TableOfContents} from './audio/TableOfContents';- [Importing assets](/docs/assets)- [Audio visualization](/docs/audio/visualization)+- [`<Video />`](/docs/media/video) tag- [`<Html5Audio />`](/docs/html5-audio) tagdiff --git a/packages/docs/docs/validating-user-videos.mdx b/packages/docs/docs/validating-user-videos.mdxindex 2cac03e68d..fb2fc60076 100644--- a/packages/docs/docs/validating-user-videos.mdx+++ b/packages/docs/docs/validating-user-videos.mdx@@ -27,13 +27,13 @@ Learn more about the supported media formats: [Video formats](/docs/miscellaneouCaveat: In `@remotion/media`, videos with a H.265 codec are supported in the regular browser, but during rendering, they fall back to [`<OffthreadVideo>`](/docs/offthreadvideo).:::-## Validation example in React+## Validation example in TypeScript:::noteThis is a simplified example showing the validation flow. In a real application, the implementation will vary depending on your upload strategy (direct upload, presigned URLs, multipart uploads, etc.) and where you store videos (S3, GCS, your own server, etc.).:::-```tsx twoslash title="ValidatedUploader.tsx"+```ts twoslash title="ValidatedUploader.ts"const canDecode = async (src: string | Blob) => {return true;};diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex 3f952c4b2e..2b9af75b06 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -1236,7 +1236,6 @@ const sidebars: SidebarsConfig = {'lambda/troubleshooting/unrecognizedclientexception','lambda/troubleshooting/bucket-disallows-acl','lambda/troubleshooting/security-token',- 'lambda/troubleshooting/chrome-133-situation',],},{diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 979cdc4538..c775956cf2 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -3554,15 +3554,6 @@ export const articles = [noAi: false,slug: 'lambda/troubleshooting/bucket-disallows-acl',},- {- id: 'chrome-133-situation',- title: 'Chrome 133 situation',- relativePath: 'docs/lambda/troubleshooting/chrome-133-situation.mdx',- compId: 'articles-docs-lambda-troubleshooting-chrome-133-situation',- crumb: 'Lambda',- noAi: false,- slug: 'lambda/troubleshooting/chrome-133-situation',- },{id: 'debug',title: 'Debugging failed Lambda renders',diff --git a/packages/docs/static/generated/articles-docs-lambda-troubleshooting-chrome-133-situation.png b/packages/docs/static/generated/articles-docs-lambda-troubleshooting-chrome-133-situation.pngdeleted file mode 100644index 34a014a165..0000000000Binary files a/packages/docs/static/generated/articles-docs-lambda-troubleshooting-chrome-133-situation.png and /dev/null differ