{"record":{"id":"04e9d902e591766a","repo":"remotion-dev/remotion","slug":"the-input-video-has-invalid-dimensions","errorCode":null,"errorMessage":"The input video has invalid dimensions.","messagePattern":"The input video has invalid dimensions\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/separate-video-layers.ts","lineNumber":275,"sourceCode":"\tif (videoTrack === null) {\n\t\tthrow new Error('The input does not contain a video track.');\n\t}\n\n\tif (!(await videoTrack.canDecode())) {\n\t\tthrow new Error('The primary video track cannot be decoded.');\n\t}\n\n\tconst [width, height] = await Promise.all([\n\t\tvideoTrack.getDisplayWidth(),\n\t\tvideoTrack.getDisplayHeight(),\n\t]);\n\tif (\n\t\t!Number.isInteger(width) ||\n\t\twidth <= 0 ||\n\t\t!Number.isInteger(height) ||\n\t\theight <= 0\n\t) {\n\t\tthrow new Error('The input video has invalid dimensions.');\n\t}\n\n\tconst [canEncodeBase, canEncodeForeground] = await Promise.all([\n\t\tcanEncodeVideo('vp9', {\n\t\t\twidth,\n\t\t\theight,\n\t\t\tquality: videoQuality,\n\t\t\talpha: 'discard',\n\t\t}),\n\t\tcanEncodeVideo('vp9', {\n\t\t\twidth,\n\t\t\theight,\n\t\t\tquality: videoQuality,\n\t\t\talpha: 'keep',\n\t\t}),\n\t]);\n\tif (!canEncodeBase || !canEncodeForeground) {\n\t\tthrow new Error(","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/separate-video-layers.ts#L257-L293","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait separateVideoLayers({src: corruptUpload}); // 0x0 dimensions\n// after\nconst repaired = await remuxWithFfmpeg(corruptUpload);\nawait separateVideoLayers({src: repaired});","handlingStrategy":"validation","validationCode":"const input = new Input({source: new BlobSource(file), formats: ALL_FORMATS});\nconst track = await input.getPrimaryVideoTrack();\nconst [w, h] = [await track.getDisplayWidth(), await track.getDisplayHeight()];\nif (!Number.isInteger(w) || w <= 0 || !Number.isInteger(h) || h <= 0) {\n  throw new Error('Source video reports invalid dimensions');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-encode or remux suspicious sources (ffmpeg rebuilds dimension metadata).","Verify integrity (checksum, complete download) of files before processing."],"tags":["mediabunny","dimensions","corrupt-file","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}