{"record":{"id":"de8626ebb0cc443a","repo":"remotion-dev/remotion","slug":"the-video-presentation-range-is-invalid","errorCode":null,"errorMessage":"The video presentation range is invalid.","messagePattern":"The video presentation range is invalid\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/video-timing.ts","lineNumber":44,"sourceCode":"\ttimestamp: number;\n\tduration: number;\n\tvideoStartTimestamp: number;\n\tvideoEndTimestamp: number;\n}): {timestamp: number; duration: number} | null => {\n\tif (!Number.isFinite(timestamp)) {\n\t\tthrow new TypeError('The video frame timestamp must be finite.');\n\t}\n\n\tif (!Number.isFinite(duration) || duration < 0) {\n\t\tthrow new TypeError('The video frame duration must be non-negative.');\n\t}\n\n\tif (\n\t\t!Number.isFinite(videoStartTimestamp) ||\n\t\t!Number.isFinite(videoEndTimestamp) ||\n\t\tvideoEndTimestamp < videoStartTimestamp\n\t) {\n\t\tthrow new TypeError('The video presentation range is invalid.');\n\t}\n\n\tconst visibleStart = Math.max(timestamp, videoStartTimestamp);\n\tconst visibleEnd = Math.min(timestamp + duration, videoEndTimestamp);\n\tif (visibleEnd <= visibleStart) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttimestamp: visibleStart - videoStartTimestamp,\n\t\tduration: visibleEnd - visibleStart,\n\t};\n};\n\nexport const getVideoProcessingProgress = ({\n\ttimestamp,\n\tduration,\n\tfirstVideoTimestamp,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/video-timing.ts#L26-L62","documentation":"getClippedVideoFrameTiming validates the presentation range: videoStartTimestamp and videoEndTimestamp must be finite and end must not be before start. An invalid range means the clip boundaries themselves are broken, so clipping cannot be computed and a TypeError is thrown.","triggerScenarios":"videoStartTimestamp or videoEndTimestamp is NaN/±Infinity, or videoEndTimestamp < videoStartTimestamp — e.g. from reversed in/out points in a trim/segment configuration or unparsed metadata.","commonSituations":"Trim config where trimStart > trimEnd, metadata fields left undefined and coerced to NaN, or mixing seconds and milliseconds so the end value computes smaller than the start.","solutions":["Check the trim/segment config: ensure end >= start and both are finite numbers","Validate video metadata was parsed (videoStartTimestamp/videoEndTimestamp !== undefined) before clipping","Fix unit conversions so start and end use the same unit","Normalize the range: if end < start after config, swap or reject the config with a clearer error"],"exampleFix":"// before\ngetClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp: end, videoEndTimestamp: start}); // swapped\n// after\nconst [s, e] = start <= end ? [start, end] : [end, start];\ngetClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp: s, videoEndTimestamp: e});","handlingStrategy":"validation","validationCode":"const hasValidRange = (s: number, e: number) =>\n  Number.isFinite(s) && Number.isFinite(e) && e >= s;\nif (!hasValidRange(videoStartTimestamp, videoEndTimestamp)) throw new Error('Invalid trim range in config');","typeGuard":"const isValidPresentationRange = (r: {start: number; end: number}): r is {start: number; end: number} =>\n  Number.isFinite(r.start) && Number.isFinite(r.end) && r.end >= r.start;","tryCatchPattern":"try {\n  const timing = getClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp, videoEndTimestamp});\n} catch (err) {\n  if (err instanceof TypeError && err.message.includes('presentation range is invalid')) {\n    console.error('Check trimStart/trimEnd in the composition config');\n    throw err; // range errors indicate config bugs; do not silently skip\n  }\n  throw err;\n}","preventionTips":["Validate trim config at load time: end >= start and both finite","Never pass undefined metadata fields through as timestamps","Normalize units before comparing start and end","Swap or reject reversed ranges with a clear config error instead of reaching the clipper"],"tags":["video-matting","timestamps","validation","typescript"],"backgroundTag":"invalid-argument-value","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}