{"record":{"id":"b6f1ad724e6db48e","repo":"remotion-dev/remotion","slug":"the-video-frame-timestamp-must-be-finite","errorCode":null,"errorMessage":"The video frame timestamp must be finite.","messagePattern":"The video frame timestamp must be finite\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/video-timing.ts","lineNumber":32,"sourceCode":"\t\tthrow new Error('Video frames must be in presentation order.');\n\t}\n\n\treturn Math.max(0, rebased);\n};\n\nexport const getClippedVideoFrameTiming = ({\n\ttimestamp,\n\tduration,\n\tvideoStartTimestamp,\n\tvideoEndTimestamp,\n}: {\n\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;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/video-timing.ts#L14-L50","documentation":"getClippedVideoFrameTiming clips a frame's visibility to the video presentation range and first validates that timestamp is a finite number. Non-finite timestamps (NaN/±Infinity) make clipping math undefined, so a TypeError is thrown early with a precise message.","triggerScenarios":"Passing a frame timestamp that is NaN or Infinity into getClippedVideoFrameTiming, usually because an upstream demuxer failed or a computed timestamp involved division by zero.","commonSituations":"Metadata not yet parsed when timing is computed, malformed container headers yielding NaN pts, or hand-built frame lists with missing timestamp fields.","solutions":["Validate/skip frames with non-finite timestamps before computing clipped timing","Ensure video metadata (start/end) is loaded before scheduling frames","Fix timestamp computation upstream (avoid 0-division, check decoder output)","Wrap in try/catch and treat the frame as missing rather than aborting the whole render"],"exampleFix":"// before\nconst timing = getClippedVideoFrameTiming({timestamp: frame.ts, duration, videoStartTimestamp, videoEndTimestamp});\n// after\nif (!Number.isFinite(frame.ts)) return null;\nconst timing = getClippedVideoFrameTiming({timestamp: frame.ts, duration, videoStartTimestamp, videoEndTimestamp});","handlingStrategy":"validation","validationCode":"const getClippedSafe = (input) =>\n  Number.isFinite(input.timestamp) ? getClippedVideoFrameTiming(input) : null;","typeGuard":"const isFiniteNumber = (t: unknown): t is number =>\n  typeof t === 'number' && Number.isFinite(t);","tryCatchPattern":"try {\n  const timing = getClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp, videoEndTimestamp});\n} catch (err) {\n  if (err instanceof TypeError && err.message.includes('timestamp must be finite')) {\n    return null; // treat frame as missing\n  }\n  throw err;\n}","preventionTips":["Validate decoder output before scheduling frames","Ensure metadata parsing completed before computing timing","Avoid arithmetic that can produce NaN (0-division, undefined operands)","Filter frame lists with Number.isFinite upfront"],"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-14T00:17:10.932Z"}