Skip to content

🎥 Make videos programmatically with React

Add delayRenderTimeoutInMilliseconds prop to <Gif> component

Jonny Burger9ebf7272518b
diff --git a/packages/docs/docs/gif/gif.mdx b/packages/docs/docs/gif/gif.mdx
index d800591497..b372fb6e04 100644
--- a/packages/docs/docs/gif/gif.mdx
+++ b/packages/docs/docs/gif/gif.mdx
@@ -112,6 +112,21 @@ Values:
- `< 1`: Slows down the GIF speed (e.g., 0.5 plays it at half speed).
- `> 1:` Speeds up the GIF speed (e.g., 2.0 plays it at double speed).
+### delayRenderTimeoutInMilliseconds
+
+_optional_
+
+Modifies the timeout of the internal [`delayRender()`](/docs/delay-render) call when loading the GIF. By default, Remotion will wait 30 seconds for the GIF to load before timing out. You can increase or decrease this timeout by passing a custom value.
+
+See: [Modifying the timeout](/docs/delay-render#modifying-the-timeout)
+
+```tsx
+<Gif
+ src="https://example.com/large-gif.gif"
+ delayRenderTimeoutInMilliseconds={60000} // 60 seconds
+/>
+```
+
## Differences to `<AnimatedImage>`
- `<Gif>` does not support animated AVIF and WebP images.
diff --git a/packages/gif/src/GifForRendering.tsx b/packages/gif/src/GifForRendering.tsx
index cd240b5aeb..6461583aab 100644
--- a/packages/gif/src/GifForRendering.tsx
+++ b/packages/gif/src/GifForRendering.tsx
@@ -19,6 +19,7 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
loopBehavior = 'loop',
playbackRate = 1,
fit = 'fill',
+ delayRenderTimeoutInMilliseconds,
...props
},
ref,
@@ -42,7 +43,9 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
const [error, setError] = useState<Error | null>(null);
const [renderHandle] = useState(() =>
- delayRender(`Rendering <Gif/> with src="${resolvedSrc}"`),
+ delayRender(`Rendering <Gif/> with src="${resolvedSrc}"`, {
+ timeoutInMilliseconds: delayRenderTimeoutInMilliseconds,
+ }),
);
const logLevel = Internals.useLogLevel();
@@ -67,7 +70,9 @@ export const GifForRendering = forwardRef<HTMLCanvasElement, RemotionGifProps>(
const controller = new AbortController();
let done = false;
let aborted = false;
- const newHandle = delayRender('Loading <Gif /> with src=' + resolvedSrc);
+ const newHandle = delayRender('Loading <Gif /> with src=' + resolvedSrc, {
+ timeoutInMilliseconds: delayRenderTimeoutInMilliseconds,
+ });
Internals.Log.verbose(
{logLevel, tag: null},
diff --git a/packages/gif/src/props.ts b/packages/gif/src/props.ts
index e6c59a0777..162b306984 100644
--- a/packages/gif/src/props.ts
+++ b/packages/gif/src/props.ts
@@ -19,6 +19,7 @@ export type RemotionGifProps = {
style?: React.CSSProperties;
loopBehavior?: GifLoopBehavior;
id?: string;
+ delayRenderTimeoutInMilliseconds?: number;
};
export type GifState = {