remotion-dev/remotion · error · TypeError
outputTimestamp must be a finite, non-negative number.
Error message
outputTimestamp must be a finite, non-negative number.
What it means
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.
Source
Thrown at packages/video-matting/src/prepare-audio.ts:236
}
}
};
return {
prime: async () => {
if (primed || finished || canceled) {
return;
}
primed = true;
await writePacketsUntil({
outputTimestamp: 0,
writeAtLeastOne: true,
});
},
writeAudioUntil: async (outputTimestamp) => {
if (!Number.isFinite(outputTimestamp) || outputTimestamp < 0) {
throw new TypeError(
'outputTimestamp must be a finite, non-negative number.',
);
}
if (outputTimestamp < lastWriteTimestamp) {
throw new RangeError(
'writeAudioUntil() timestamps must be monotonically increasing.',
);
}
if (finished || canceled) {
return;
}
lastWriteTimestamp = outputTimestamp;
await writePacketsUntil({
outputTimestamp: Math.min(
outputTimestamp,View on GitHub (pinned to b2f4e34732)
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.
Example fix
// before await audio.writeAudioUntil(frame / fps); // fps undefined -> NaN // after const t = frame / (fps ?? 30); if (Number.isFinite(t) && t >= 0) await audio.writeAudioUntil(t);
Defensive patterns
Strategy: validation
Validate before calling
const isValidTs = (t: unknown) => typeof t === 'number' && Number.isFinite(t) && t >= 0;
if (!isValidTs(t)) throw new TypeError('bad timestamp: ' + t); Type guard
const isValidTimestamp = (t: unknown): t is number => typeof t === 'number' && Number.isFinite(t) && t >= 0;
Try / catch
try { await audio.writeAudioUntil(t); } catch (e) { if (e instanceof TypeError && e.message.includes('outputTimestamp')) { console.error('invalid timestamp', t); return; } throw e; } Prevention
- Validate computed timestamps before each call
- Avoid sentinel values like -1 for timestamps
- Parse numeric metadata with Number() and check Number.isFinite
When it happens
Trigger: Calling writeAudioUntil(-0.5), writeAudioUntil(NaN), writeAudioUntil(Infinity), or writeAudioUntil(undefined) on the returned audio pipeline handle.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Argument missing for parameter "frame"
- Argument passed for "frame" is not a number: ${frame}
- You have passed a volume of type ${typeof props.volume} to y
- You have passed a volume below 0 to your <${component} /> co
- You have passed a playbackRate of type ${typeof props.playba
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/0ef5eb4474fd2d4c.
Report an issue: GitHub.