Skip to content

🎥 Make videos programmatically with React

improve legacy docs

JonnyBurgerebcbc674b037
diff --git a/packages/docs/docs/non-seekable-media.mdx b/packages/docs/docs/non-seekable-media.mdx
index 83b542497b..e529f08422 100644
--- a/packages/docs/docs/non-seekable-media.mdx
+++ b/packages/docs/docs/non-seekable-media.mdx
@@ -17,50 +17,15 @@ Please see https://remotion.dev/docs/non-seekable-media for assistance.
## Meaning
-This error could occur due to one of two reasons:
-
-<Step>1</Step> A video or audio has entered the video while not being preloaded. <br/><br/>
-
-Most commonly this happens when an audio has been replaced while the video is playing, for example due to user input changing. You can fix this by first [preloading the assets](/docs/player/preloading) before you mount them in an audio tag - for this the assets need to support CORS.
-
-```tsx twoslash
-const setAudioUrl = (url: string) => {};
-// ---cut---
-
-import { prefetch, staticFile } from "remotion";
-
-const MyComp = () => {
- return (
- <select
- onChange={(e) => {
- prefetch(e.target.value)
- .waitUntilDone()
- .then(() => {
- setAudioUrl(e.target.value);
- });
- }}
- >
- <option value={staticFile("sample.mp3")}>Audio 0</option>
- <option value={staticFile("sample2.mp3")}>Audio 1</option>
- <option value={staticFile("sample3.mp3")}>Audio 2</option>
- </select>
- );
-};
-```
-
-<Step>2</Step> A video or audio was provided that cannot be seeked to an arbitrary time.
-
The cause for this is that when requesting the media file, either:
- No `Content-Range` HTTP header has been sent by the server, making it impossible for the browser and therefore for Remotion to seek the media.
- No `Content-Length` HTTP header has been sent by the server, also preventing seeking.
-- The file does not support [Faststart](https://www.videoconverterfactory.com/tips/mp4-fast-start.html)
+- The file does not support [Faststart](https://www.videoconverterfactory.com/tips/mp4-fast-start.html) or equivalent.
You can verify that this is the problem by opening the video or audio in a new tab and observe that you cannot seek the media.
-You can determine if a video supports seeking, you can use the [`getVideoMetadata()`](/docs/renderer/get-video-metadata) function.
-
-<Step>3</Step> Media was prevented from being loaded into a video tag.
+Alternatively, it could be that the media was prevented from being loaded into a video tag.
The following headers can prevent a file from being included:
@@ -78,10 +43,6 @@ Those videos files cannot be loaded due to policy from the server.
Consider one of these solutions:
+- Use the [`<Video>`](/docs/media/video) component from `@remotion/media`, which can handle more cases.
- Serve the media from a webhost that supports the `Range` header and returns a `Content-Length` and `Content-Range` header.
-- Download the media and import it locally using an `import` or `require()` statement.
-- Use the [`<Video>`](/docs/media/video) component from `@remotion/media`, which will render the video fine. You may still see problems during playback in the Remotion Studio or the [`<Player>`](/docs/player).
-
-## See also
-
-- [getVideoMetadata()](/docs/renderer/get-video-metadata)
+- Download the media and import it locally using `staticFile`.
diff --git a/packages/docs/docs/player/preloading.mdx b/packages/docs/docs/player/preloading.mdx
index 55f4b1dc7c..1a07127ba7 100644
--- a/packages/docs/docs/player/preloading.mdx
+++ b/packages/docs/docs/player/preloading.mdx
@@ -5,15 +5,18 @@ title: 'Preloading assets'
crumb: '@remotion/player'
---
-By default, assets such as videos, audio, or images will only be loaded as they enter the video. When using the [Remotion Player](/docs/terminology/player), you may want to preload those assets beforehand to make them play immediately once they enter the video.
+Assets should be preloaded before entering the scene so they are ready once they should be played.
-Two ways of preloading are supported:
+The recommended way is to use a [**default premounting for all items in the `<Player />`**](/docs/player/premounting#default-premounting-in-the-player).
-- Signaling to the browser that assets should be loaded using the [`@remotion/preload`](/docs/preload) APIs
-- Fetching the assets beforehand and then playing them locally using [`prefetch()`](/docs/prefetch)
+This article documents 2 other, **not recommended** approaches which were developed when Remotion was not yet as mature.
## Preloading videos using `@remotion/preload`
+:::warn
+Don't use this for preloading audio and video: It only works for native HTML5 tags such as `<video>` and `<audio>`, but not for Remotion's own implementations such as `<Video>` and `<Audio>`.
+:::
+
By preloading, a `<link type='preload'>` tag is placed on the page, signaling to the browser that it may start loading the media.
For videos, use [`preloadVideo()`](/docs/preload/preload-video) API, for audio use [`preloadAudio()`](/docs/preload/preload-audio), for images use [`preloadImage()`](/docs/preload/preload-image). Perform the preload outside a component or inside an [`useEffect()`](https://react.dev/reference/react/useEffect).
@@ -32,8 +35,8 @@ unpreloadAudio();
_Available in v3.2.23_
-:::note
-Prefetch is not recommended for most cases. [See recommendations](/docs/troubleshooting/player-flicker#strategies).
+:::warn
+Don't use this: It first needs to download the whole media and keep it in memory.
:::
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).
@@ -54,10 +57,6 @@ free();
## `@remotion/preload` vs. `prefetch()`
-[`prefetch()`](/docs/prefetch) is a more reliable way of ensuring the media is ready when it needs to displayed, but the asset needs to be downloaded in full for it.
-
-[`@remotion/preload`](/docs/preload) is preferrable if the asset is large since you don't have to wait for it finish downloading,
-
<table>
<tr>
<th></th>
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 0c88a4e77c..f37b60a1ce 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -1489,8 +1489,8 @@ const sidebars: SidebarsConfig = {
'player/current-time',
'troubleshooting/player-flicker',
'player/buffer-state',
- 'player/preloading',
'player/premounting',
+ 'player/preloading',
'player/best-practices',
'player/drag-and-drop/index',
'player/custom-controls',