{"record":{"id":"0ef5eb4474fd2d4c","repo":"remotion-dev/remotion","slug":"outputtimestamp-must-be-a-finite-non-negative-num","errorCode":null,"errorMessage":"outputTimestamp must be a finite, non-negative number.","messagePattern":"outputTimestamp must be a finite, non-negative number\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/prepare-audio.ts","lineNumber":236,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\tprime: async () => {\n\t\t\t\tif (primed || finished || canceled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tprimed = true;\n\t\t\t\tawait writePacketsUntil({\n\t\t\t\t\toutputTimestamp: 0,\n\t\t\t\t\twriteAtLeastOne: true,\n\t\t\t\t});\n\t\t\t},\n\t\t\twriteAudioUntil: async (outputTimestamp) => {\n\t\t\t\tif (!Number.isFinite(outputTimestamp) || outputTimestamp < 0) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t'outputTimestamp must be a finite, non-negative number.',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (outputTimestamp < lastWriteTimestamp) {\n\t\t\t\t\tthrow new RangeError(\n\t\t\t\t\t\t'writeAudioUntil() timestamps must be monotonically increasing.',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (finished || canceled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlastWriteTimestamp = outputTimestamp;\n\t\t\t\tawait writePacketsUntil({\n\t\t\t\t\toutputTimestamp: Math.min(\n\t\t\t\t\t\toutputTimestamp,","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/prepare-audio.ts#L218-L254","documentation":"The writeAudioUntil() handle returned by prepareAudio() validates its outputTimestamp argument: it must be a finite number >= 0. Negative, NaN, Infinity, or non-number values are rejected with a TypeError so the WebCodecs audio writer never receives an invalid media timestamp.","triggerScenarios":"Calling writeAudioUntil(-0.5), writeAudioUntil(NaN), writeAudioUntil(Infinity), or writeAudioUntil(undefined) on the returned audio pipeline handle.","commonSituations":"Timestamp arithmetic producing NaN (e.g. dividing by an undefined fps or duration); timestamps initialized to -1 as a sentinel; passing a string from JSON-parsed timeline data.","solutions":["Pass a finite non-negative number of seconds for outputTimestamp.","Guard computed timestamps with Number.isFinite(t) && t >= 0 before calling.","Fix the upstream arithmetic (undefined duration/fps) that produces NaN or negative values.","Clamp negative values to 0 if a sentinel is being used."],"exampleFix":"// before\nawait audio.writeAudioUntil(frame / fps); // fps undefined -> NaN\n// after\nconst t = frame / (fps ?? 30);\nif (Number.isFinite(t) && t >= 0) await audio.writeAudioUntil(t);","handlingStrategy":"validation","validationCode":"const isValidTs = (t: unknown) => typeof t === 'number' && Number.isFinite(t) && t >= 0;\nif (!isValidTs(t)) throw new TypeError('bad timestamp: ' + t);","typeGuard":"const isValidTimestamp = (t: unknown): t is number => typeof t === 'number' && Number.isFinite(t) && t >= 0;","tryCatchPattern":"try { await audio.writeAudioUntil(t); } catch (e) { if (e instanceof TypeError && e.message.includes('outputTimestamp')) { console.error('invalid timestamp', t); return; } throw e; }","preventionTips":["Validate computed timestamps before each call","Avoid sentinel values like -1 for timestamps","Parse numeric metadata with Number() and check Number.isFinite"],"tags":["typeerror","validation","webcodecs"],"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"}