{"record":{"id":"a5fd4699f4c12f90","repo":"remotion-dev/remotion","slug":"videostarttimestamp-must-be-a-finite-number","errorCode":null,"errorMessage":"videoStartTimestamp must be a finite number.","messagePattern":"videoStartTimestamp must be a finite number\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/prepare-audio.ts","lineNumber":60,"sourceCode":"\tbaseOutput,\n\tforegroundOutput,\n\tdestination,\n\tvideoStartTimestamp,\n\tvideoEndTimestamp,\n\taudioQuality,\n\tforceTranscode,\n}: {\n\tinput: Input;\n\tbaseOutput: Output<WebMOutputFormat, BaseTarget>;\n\tforegroundOutput: Output<WebMOutputFormat, ForegroundTarget>;\n\tdestination: VideoMattingAudioDestination;\n\tvideoStartTimestamp: number;\n\tvideoEndTimestamp: number;\n\taudioQuality: Quality | null;\n\tforceTranscode: boolean;\n}): Promise<PreparedVideoMattingAudio> => {\n\tif (!Number.isFinite(videoStartTimestamp)) {\n\t\tthrow new TypeError('videoStartTimestamp must be a finite number.');\n\t}\n\n\tif (!Number.isFinite(videoEndTimestamp)) {\n\t\tthrow new TypeError('videoEndTimestamp must be a finite number.');\n\t}\n\n\tif (videoEndTimestamp < videoStartTimestamp) {\n\t\tthrow new RangeError(\n\t\t\t'videoEndTimestamp must be greater than or equal to videoStartTimestamp.',\n\t\t);\n\t}\n\n\tif (typeof forceTranscode !== 'boolean') {\n\t\tthrow new TypeError('forceTranscode must be a boolean.');\n\t}\n\n\tif (destination === 'none') {\n\t\treturn {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/prepare-audio.ts#L42-L78","documentation":"prepareAudio validates its videoStartTimestamp argument with Number.isFinite and throws a TypeError when it is not a finite number (NaN, Infinity, -Infinity or a non-number from JS callers). Timestamps drive audio trimming, so non-finite values cannot be planned.","triggerScenarios":"Passing NaN/Infinity as videoStartTimestamp to prepareAudio, or a value computed from division by zero, missing metadata, or unparsed JSON.","commonSituations":"Metadata lookup returned null and the code did arithmetic with it; dividing durations that were undefined; JS (non-TS) callers passing strings that silently become NaN in arithmetic.","solutions":["Ensure videoStartTimestamp is computed from valid, finite numbers before calling prepareAudio","Check upstream metadata for null/undefined before deriving the timestamp","Default to 0 when the value cannot be determined"],"exampleFix":"// before\nconst start = totalDuration / fpsCount; // NaN when fpsCount is 0\n// after\nconst start = fpsCount > 0 && Number.isFinite(totalDuration) ? totalDuration / fpsCount : 0;","handlingStrategy":"validation","validationCode":"if (!Number.isFinite(videoStartTimestamp)) {\n  throw new TypeError('videoStartTimestamp must be finite before calling prepareAudio');\n}\n","typeGuard":"const isFiniteNumber = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v);\n","tryCatchPattern":"try {\n  await prepareAudio({videoStartTimestamp, ...});\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('videoStartTimestamp')) {\n    videoStartTimestamp = 0;\n  }\n  throw e;\n}\n","preventionTips":["Coerce metadata to numbers before arithmetic","Guard divisions that produce NaN/Infinity","Default invalid timestamps to 0 with a warning"],"tags":["validation","timestamp","nan"],"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"}