🎥 Make videos programmatically with React
rendering + docs
Jonny Burger055de35c270d
diff --git a/packages/core/src/video/VideoForRendering.tsx b/packages/core/src/video/VideoForRendering.tsxindex b8d7d5740b..0725518a7d 100644--- a/packages/core/src/video/VideoForRendering.tsx+++ b/packages/core/src/video/VideoForRendering.tsx@@ -204,8 +204,14 @@ const VideoForRenderingForwardFunction: React.ForwardRefRenderFunction<const errorHandler = () => {if (current?.error) {console.error('Error occurred in video', current?.error);++ // If user is handling the error, we don't cause an unhandled exception+ if (onError) {+ return;+ }+throw new Error(- `The browser threw an error while playing the video ${props.src}: Code ${current.error.code} - ${current?.error?.message}. See https://remotion.dev/docs/media-playback-error for help`+ `The browser threw an error while playing the video ${props.src}: Code ${current.error.code} - ${current?.error?.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`);} else {throw new Error('The browser threw an error');@@ -228,6 +234,7 @@ const VideoForRenderingForwardFunction: React.ForwardRefRenderFunction<videoConfig.fps,frame,mediaStartsAt,+ onError,]);const {src} = props;diff --git a/packages/docs/docs/media-playback-error.md b/packages/docs/docs/media-playback-error.mdindex 2802930f40..975407bd69 100644--- a/packages/docs/docs/media-playback-error.md+++ b/packages/docs/docs/media-playback-error.md@@ -48,6 +48,10 @@ Open the DevTools and go to the network tab to validate that this is the case.You might be importing a video that is not compatible with Chrome at all, e.g. FLV.+## Recover from this error <AvailableFrom v="3.3.89" />++You can handle this error and replace it with a different video by passing the `onError()` prop to the `<Video>` or `<OffthreadVideo>` component.+## See also- [Codec support](/docs/config#setbrowserexecutable)diff --git a/packages/docs/docs/offthreadvideo.md b/packages/docs/docs/offthreadvideo.mdindex 8ea3e612e8..5b85a7962d 100644--- a/packages/docs/docs/offthreadvideo.md+++ b/packages/docs/docs/offthreadvideo.md@@ -50,11 +50,15 @@ The props [`onError`](/docs/img#onerror), `className` and `style` are supportedEither `jpeg` or `png`. Default `jpeg`.With `png`, transparent videos (VP8, VP9, ProRes) can be displayed, however it is around 40% slower, with VP8 videos being [much slower](/docs/slow-method-to-extract-frame).-## `allowAmplificationDuringRender` <AvailableFrom v="3.3.17" />+### `allowAmplificationDuringRender` <AvailableFrom v="3.3.17" />Make values for [`volume`](/docs/video#volume) greater than `1` result in amplification during renders.During Preview, the volume will be limited to `1`, since the browser cannot amplify audio.+### `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.+## Performance tipsAvoid embedding a video beyond it's end (for example: Rendering a 5 second video inside 10 second composition). To create parity with the `<Video>` element, the video still displays its last frame in that case. However, to fetch the last frame specifically is a significantly more expensive operation than a frame from a known timestamp.diff --git a/packages/docs/docs/video.md b/packages/docs/docs/video.mdindex 02765e3361..04547f407a 100644--- a/packages/docs/docs/video.md+++ b/packages/docs/docs/video.md@@ -178,15 +178,19 @@ export const MyComposition = () => {};```-## `acceptableTimeShiftInSeconds` <AvailableFrom v="3.2.42" />+### `acceptableTimeShiftInSeconds` <AvailableFrom v="3.2.42" />During [Preview](/docs/terminology#remotion-preview) or in the [Remotion Player](/docs/player), Remotion will seek the video if it gets too much out of sync with Remotion's internal time - be it due to the video 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.-## `allowAmplificationDuringRender` <AvailableFrom v="3.3.17" />+### `allowAmplificationDuringRender` <AvailableFrom v="3.3.17" />Make values for [`volume`](#volume) greater than `1` result in amplification during renders.During Preview, the volume will be limited to `1`, since the browser cannot amplify audio.+### `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.+## Speed up renders for video with silent audioRemotion will download the whole video during render in order to mix its audio. If the video contains a silent audio track, you can add the muted property to signal to Remotion that it does not need to download the video and make the render more efficient.