packages/docs/docs/media/fallback.mdx
Sometimes, a media file cannot be embedded using @remotion/media's <Video> and <Audio> tags.
In such cases, a fallback to <OffthreadVideo> or <Html5Audio> from the remotion package is attempted.
Here are some cases where @remotion/media may fall back to <OffthreadVideo> or <Html5Audio> from remotion:
If @remotion/media falls back to another tag, then a warning message will be logged in the render:
Cannot decode /public/video-h265.mp4, falling back to <OffthreadVideo>
If you are rendering on an environment where the logs are not immediately visible (e.g. Lambda), observe whether a fallback has happened by visiting the logs (e.g. CloudWatch).
To prevent <Video> from falling back to <OffthreadVideo>, set the disallowFallbackToOffthreadVideo prop:
import {Video} from '@remotion/media';
export const MyComp: React.FC = () => {
return <Video src="https://remotion.media/video.mp4" disallowFallbackToOffthreadVideo />;
};
To prevent <Audio> from falling back to <Html5Audio> from remotion, set the disallowFallbackToHtml5Audio prop:
import {Audio} from '@remotion/media';
export const MyComp: React.FC = () => {
return <Audio src="https://remotion.media/audio.mp3" disallowFallbackToHtml5Audio />;
};
If a fallback is prevented, the render will be cancelled instead.
loop prop during fallbackThe loop prop of <Video> is handled differently depending on the environment:
During preview, the fallback uses <Html5Video>, which natively supports the loop prop. Looping works as expected.
During rendering, <OffthreadVideo> does not natively support looping. To work around this, @remotion/media attempts to determine the duration of the video and automatically wraps <OffthreadVideo> in a <Loop> component.
To ensure looping works reliably during rendering, make sure:
When using @remotion/web-renderer for client-side rendering, fallback to <OffthreadVideo> or <Html5Audio> is not possible.
This is because these fallback components require server-side capabilities that are not available in the browser.
If a media file cannot be rendered using @remotion/media during client-side rendering, the render will fail with an error message describing the issue.