remotion-dev/remotion · error · Error
The input video has invalid dimensions.
Error message
The input video has invalid dimensions.
What it means
The decoded video track's display width/height (fetched via getDisplayWidth/getDisplayHeight) were not positive integers. The library needs concrete pixel dimensions to size output canvases and VP9 encoders, so non-integer or non-positive dimensions are rejected. This indicates a corrupt container header or a demuxer that could not determine display dimensions.
Source
Thrown at packages/video-matting/src/separate-video-layers.ts:275
if (videoTrack === null) {
throw new Error('The input does not contain a video track.');
}
if (!(await videoTrack.canDecode())) {
throw new Error('The primary video track cannot be decoded.');
}
const [width, height] = await Promise.all([
videoTrack.getDisplayWidth(),
videoTrack.getDisplayHeight(),
]);
if (
!Number.isInteger(width) ||
width <= 0 ||
!Number.isInteger(height) ||
height <= 0
) {
throw new Error('The input video has invalid dimensions.');
}
const [canEncodeBase, canEncodeForeground] = await Promise.all([
canEncodeVideo('vp9', {
width,
height,
quality: videoQuality,
alpha: 'discard',
}),
canEncodeVideo('vp9', {
width,
height,
quality: videoQuality,
alpha: 'keep',
}),
]);
if (!canEncodeBase || !canEncodeForeground) {
throw new Error(View on GitHub (pinned to b2f4e34732)
Solutions
- Re-download or re-export the source file — verify dimensions are sane (e.g. via ffprobe).
- Remux/transcode the file with ffmpeg (ffmpeg -i in.mp4 -c copy fixed.mp4) to rebuild metadata.
- If you generate the input programmatically, ensure width/height are set before muxing.
Example fix
// before
await separateVideoLayers({src: corruptUpload}); // 0x0 dimensions
// after
const repaired = await remuxWithFfmpeg(corruptUpload);
await separateVideoLayers({src: repaired}); Defensive patterns
Strategy: validation
Validate before calling
const input = new Input({source: new BlobSource(file), formats: ALL_FORMATS});
const track = await input.getPrimaryVideoTrack();
const [w, h] = [await track.getDisplayWidth(), await track.getDisplayHeight()];
if (!Number.isInteger(w) || w <= 0 || !Number.isInteger(h) || h <= 0) {
throw new Error('Source video reports invalid dimensions');
} Prevention
- Re-encode or remux suspicious sources (ffmpeg rebuilds dimension metadata).
- Verify integrity (checksum, complete download) of files before processing.
When it happens
Trigger: A media file with corrupt/zeroed tkhd/stsd dimension metadata, a streamed placeholder that reports 0x0, or a display-aspect-ratio-only container missing pixel dimensions.
Common situations: Damaged downloads (truncated mp4 with missing moov box fields); files produced by broken muxers; synthetic test files with unset dimensions; rotated videos with malformed display matrix.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Scale must be greater than 0
- The "${nameOfProp}" prop ${location} must be a number, but y
- The "${nameOfProp}" prop ${location} must not be NaN, but is
- The "${nameOfProp}" prop ${location} must be finite, but is
- The "${nameOfProp}" prop ${location} must be an integer, but
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/04e9d902e591766a.
Report an issue: GitHub.