remotion-dev/remotion · error · TypeError
You passed in a function to the volume prop but it returned
Error message
You passed in a function to the volume prop but it returned a non-finite number for frame ${frame}. What it means
TypeError thrown by `evaluateVolume` when the volume callback returns a non-finite number (Infinity or -Infinity). This passes the typeof number and NaN checks but fails `Number.isFinite`. Usually caused by division by zero producing Infinity, or unbounded arithmetic.
Source
Thrown at packages/core/src/volume-prop.ts:34
if (typeof volume === 'undefined') {
return Number(mediaVolume);
}
const evaluated = volume(frame) * mediaVolume;
if (typeof evaluated !== 'number') {
throw new TypeError(
`You passed in a a function to the volume prop but it did not return a number but a value of type ${typeof evaluated} for frame ${frame}`,
);
}
if (Number.isNaN(evaluated)) {
throw new TypeError(
`You passed in a function to the volume prop but it returned NaN for frame ${frame}.`,
);
}
if (!Number.isFinite(evaluated)) {
throw new TypeError(
`You passed in a function to the volume prop but it returned a non-finite number for frame ${frame}.`,
);
}
return Math.max(0, evaluated);
};
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Clamp the result: `return Math.min(1, Math.max(0, value));`.
- Guard zero divisors before dividing.
- Return `Number.isFinite(v) ? v : 0` as a final safety net.
Example fix
// before
<Video src={s} volume={(f) => 1 / (100 - f)} /> // f=100 -> Infinity
// after
<Video src={s} volume={(f) => {
const v = 1 / (100 - f);
return Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : 0;
}} /> Defensive patterns
Strategy: validation
Validate before calling
const safeVolume = (v: (f: number) => number, frames: number[]) => {
for (const f of frames) {
if (!Number.isFinite(v(f))) throw new Error(`volume non-finite at frame ${f}`);
}
}; Type guard
const returnsFinite = (v: (f: number) => number, f: number): boolean => Number.isFinite(v(f));
Prevention
- Clamp volume output with Math.min/Math.max to [0,1].
- Avoid unbounded exponential growth over many frames.
- Use a final `Number.isFinite(v) ? v : 0` fallback.
When it happens
Trigger: A volume function that divides a non-zero numerator by zero (`1/0` -> Infinity), or multiplies toward Infinity. At least one frame yields an infinite value.
Common situations: Envelope/fade math dividing by an elapsed-time delta that is 0 mid-curve; exponential growth `Math.pow(base, f)` with base > 1 over many frames; accumulating sums that overflow.
Related errors
- You have passed a volume of type ${typeof props.volume} to y
- You have passed a volume below 0 to your <${component} /> co
- You passed in a a function to the volume prop but it did not
- You passed in a function to the volume prop but it returned
- Volume was set to ${volume}, but regular volume is 1, not 10
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/260e5060825c539c.
Report an issue: GitHub.