remotion-dev/remotion · error · TypeError
videoStartTimestamp must be a finite number.
Error message
videoStartTimestamp must be a finite number.
What it means
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.
Source
Thrown at packages/video-matting/src/prepare-audio.ts:60
baseOutput,
foregroundOutput,
destination,
videoStartTimestamp,
videoEndTimestamp,
audioQuality,
forceTranscode,
}: {
input: Input;
baseOutput: Output<WebMOutputFormat, BaseTarget>;
foregroundOutput: Output<WebMOutputFormat, ForegroundTarget>;
destination: VideoMattingAudioDestination;
videoStartTimestamp: number;
videoEndTimestamp: number;
audioQuality: Quality | null;
forceTranscode: boolean;
}): Promise<PreparedVideoMattingAudio> => {
if (!Number.isFinite(videoStartTimestamp)) {
throw new TypeError('videoStartTimestamp must be a finite number.');
}
if (!Number.isFinite(videoEndTimestamp)) {
throw new TypeError('videoEndTimestamp must be a finite number.');
}
if (videoEndTimestamp < videoStartTimestamp) {
throw new RangeError(
'videoEndTimestamp must be greater than or equal to videoStartTimestamp.',
);
}
if (typeof forceTranscode !== 'boolean') {
throw new TypeError('forceTranscode must be a boolean.');
}
if (destination === 'none') {
return {View on GitHub (pinned to b2f4e34732)
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
Example fix
// before const start = totalDuration / fpsCount; // NaN when fpsCount is 0 // after const start = fpsCount > 0 && Number.isFinite(totalDuration) ? totalDuration / fpsCount : 0;
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isFinite(videoStartTimestamp)) {
throw new TypeError('videoStartTimestamp must be finite before calling prepareAudio');
}
Type guard
const isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
Try / catch
try {
await prepareAudio({videoStartTimestamp, ...});
} catch (e) {
if (e instanceof TypeError && e.message.includes('videoStartTimestamp')) {
videoStartTimestamp = 0;
}
throw e;
}
Prevention
- Coerce metadata to numbers before arithmetic
- Guard divisions that produce NaN/Infinity
- Default invalid timestamps to 0 with a warning
When it happens
Trigger: Passing NaN/Infinity as videoStartTimestamp to prepareAudio, or a value computed from division by zero, missing metadata, or unparsed JSON.
Common situations: 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.
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
- videoEndTimestamp must be a finite number.
- Argument passed to "${api}" for param "${param}" is ${JSON.s
- Invalid timestamp:${time}
- Threshold is NaN
- Frame ${frame} is not finite
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/a5fd4699f4c12f90.
Report an issue: GitHub.