remotion-dev/remotion · error · TypeError
The video presentation range is invalid.
Error message
The video presentation range is invalid.
What it means
getClippedVideoFrameTiming validates the presentation range: videoStartTimestamp and videoEndTimestamp must be finite and end must not be before start. An invalid range means the clip boundaries themselves are broken, so clipping cannot be computed and a TypeError is thrown.
Source
Thrown at packages/video-matting/src/video-timing.ts:44
timestamp: number;
duration: number;
videoStartTimestamp: number;
videoEndTimestamp: number;
}): {timestamp: number; duration: number} | null => {
if (!Number.isFinite(timestamp)) {
throw new TypeError('The video frame timestamp must be finite.');
}
if (!Number.isFinite(duration) || duration < 0) {
throw new TypeError('The video frame duration must be non-negative.');
}
if (
!Number.isFinite(videoStartTimestamp) ||
!Number.isFinite(videoEndTimestamp) ||
videoEndTimestamp < videoStartTimestamp
) {
throw new TypeError('The video presentation range is invalid.');
}
const visibleStart = Math.max(timestamp, videoStartTimestamp);
const visibleEnd = Math.min(timestamp + duration, videoEndTimestamp);
if (visibleEnd <= visibleStart) {
return null;
}
return {
timestamp: visibleStart - videoStartTimestamp,
duration: visibleEnd - visibleStart,
};
};
export const getVideoProcessingProgress = ({
timestamp,
duration,
firstVideoTimestamp,View on GitHub (pinned to b2f4e34732)
Solutions
- Check the trim/segment config: ensure end >= start and both are finite numbers
- Validate video metadata was parsed (videoStartTimestamp/videoEndTimestamp !== undefined) before clipping
- Fix unit conversions so start and end use the same unit
- Normalize the range: if end < start after config, swap or reject the config with a clearer error
Example fix
// before
getClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp: end, videoEndTimestamp: start}); // swapped
// after
const [s, e] = start <= end ? [start, end] : [end, start];
getClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp: s, videoEndTimestamp: e}); Defensive patterns
Strategy: validation
Validate before calling
const hasValidRange = (s: number, e: number) =>
Number.isFinite(s) && Number.isFinite(e) && e >= s;
if (!hasValidRange(videoStartTimestamp, videoEndTimestamp)) throw new Error('Invalid trim range in config'); Type guard
const isValidPresentationRange = (r: {start: number; end: number}): r is {start: number; end: number} =>
Number.isFinite(r.start) && Number.isFinite(r.end) && r.end >= r.start; Try / catch
try {
const timing = getClippedVideoFrameTiming({timestamp, duration, videoStartTimestamp, videoEndTimestamp});
} catch (err) {
if (err instanceof TypeError && err.message.includes('presentation range is invalid')) {
console.error('Check trimStart/trimEnd in the composition config');
throw err; // range errors indicate config bugs; do not silently skip
}
throw err;
} Prevention
- Validate trim config at load time: end >= start and both finite
- Never pass undefined metadata fields through as timestamps
- Normalize units before comparing start and end
- Swap or reject reversed ranges with a clear config error instead of reaching the clipper
When it happens
Trigger: videoStartTimestamp or videoEndTimestamp is NaN/±Infinity, or videoEndTimestamp < videoStartTimestamp — e.g. from reversed in/out points in a trim/segment configuration or unparsed metadata.
Common situations: Trim config where trimStart > trimEnd, metadata fields left undefined and coerced to NaN, or mixing seconds and milliseconds so the end value computes smaller than the start.
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
- Video timestamps must be finite numbers.
- The video frame timestamp must be finite.
- A numeric bitrate must be a positive integer.
- The video frame duration must be non-negative.
- Video frame durations must be non-negative.
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/de8626ebb0cc443a.
Report an issue: GitHub.