remotion-dev/remotion · error · Error
Scale must be greater than 0
Error message
Scale must be greater than 0
What it means
Thrown by calculateNewSizeAfterResizing when resizeOperation.mode === 'scale' and the supplied scale is <= 0. The function multiplies width/height by scale, so a zero or negative scale would produce invalid (zero or negative) dimensions.
Source
Thrown at packages/convert/app/lib/calculate-new-dimensions-from-dimensions.ts:65
},
needsToBeMultipleOfTwo,
});
}
if (resizeOperation.mode === 'max-width') {
const width = Math.min(dimensions.width, resizeOperation.maxWidth);
return ensureMultipleOfTwo({
dimensions: {
width,
height: Math.round((width / dimensions.width) * dimensions.height),
},
needsToBeMultipleOfTwo,
});
}
if (resizeOperation.mode === 'scale') {
if (resizeOperation.scale <= 0) {
throw new Error('Scale must be greater than 0');
}
const width = Math.round(dimensions.width * resizeOperation.scale);
const height = Math.round(dimensions.height * resizeOperation.scale);
return ensureMultipleOfTwo({
dimensions: {
width,
height,
},
needsToBeMultipleOfTwo,
});
}
throw new Error('Invalid resizing mode ' + (resizeOperation satisfies never));
};
export const normalizeVideoRotation = (rotation: number) => {
return ((rotation % 360) + 360) % 360;View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Clamp the scale input to a small positive minimum (e.g. 0.01) before constructing the resize operation.
- Validate the resize config at the form/UI boundary so scale must be a positive finite number.
- Default scale to 1 when the field is missing or invalid.
Example fix
// before
const scale = Number(userInput); // 0 or negative allowed
resizeOperation = {mode: 'scale', scale};
// after
const scale = Math.max(0.01, Number(userInput) || 1);
if (!Number.isFinite(scale) || scale <= 0) {
throw new Error('Scale must be a positive number');
}
resizeOperation = {mode: 'scale', scale}; Defensive patterns
Strategy: validation
Validate before calling
function isValidScale(scale: number): boolean {
return Number.isFinite(scale) && scale > 0;
}
if (!isValidScale(resizeOperation.scale)) throw new Error('Scale must be a positive finite number'); Type guard
function isValidResize(op: MediabunnyResize | null): boolean {
if (!op) return true;
if (op.mode === 'scale') return Number.isFinite(op.scale) && op.scale > 0;
return true;
} Try / catch
try {
return calculateNewSizeAfterResizing({...});
} catch (e) {
if (e.message === 'Scale must be greater than 0') return dimensions; // ignore resize
throw e;
} Prevention
- Clamp scale inputs at the UI boundary to a positive minimum.
- Validate serialized resize config on load.
- Default missing scale fields to 1.
When it happens
Trigger: Passing a MediabunnyResize of mode 'scale' with scale = 0, a negative number, or NaN (NaN <= 0 is false but yields NaN dims elsewhere). Direct misuse of the resize API or a UI control that allows zero/negative scale values.
Common situations: A slider bound to scale that can reach zero; deserialized config with a missing/zeroed scale field; division or parsing that yields a negative scale.
Related errors
- Unsupported rotation: ${rotation}
- inputRange must contain only numbers
- outputStyles must contain only objects
- Argument passed to "${api}" for param "${param}" is undefine
- setImageSequence accepts a Boolean Value
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/c1edf0e2b3a879ef.
Report an issue: GitHub.