remotion-dev/remotion · error · Error
${path}.confidence must be between 0 and 1.
Error message
${path}.confidence must be between 0 and 1. What it means
parseCaptionFile requires that when a caption's confidence is a number, it lies between 0 and 1 inclusive. Values outside that range (e.g. percentages like 95 instead of 0.95) are rejected with the offending caption's index path.
Source
Thrown at packages/studio/src/components/parse-caption-file.ts:70
}
if (caption.endMs < caption.startMs) {
throw new Error(`${path}.endMs must not be earlier than startMs.`);
}
if (caption.timestampMs !== null && !isFiniteNumber(caption.timestampMs)) {
throw new Error(`${path}.timestampMs must be a finite number or null.`);
}
if (caption.confidence !== null && !isFiniteNumber(caption.confidence)) {
throw new Error(`${path}.confidence must be a finite number or null.`);
}
if (
typeof caption.confidence === 'number' &&
(caption.confidence < 0 || caption.confidence > 1)
) {
throw new Error(`${path}.confidence must be between 0 and 1.`);
}
if (
caption.pageBreakAfter !== undefined &&
typeof caption.pageBreakAfter !== 'boolean'
) {
throw new Error(
`${path}.pageBreakAfter must be a boolean when provided.`,
);
}
if (previousStart !== null && caption.startMs < previousStart) {
throw new Error(`${path}.startMs is out of timestamp order.`);
}
previousStart = caption.startMs;
}
View on GitHub (pinned to b2f4e34732)
Solutions
- Divide percentage values by 100: 95 -> 0.95
- Clamp confidence to [0, 1] in the export script
- Set confidence to null if the scale is unknown
Example fix
// before
{"text": "hi", "startMs": 0, "endMs": 1000, "confidence": 95}
// after
{"text": "hi", "startMs": 0, "endMs": 1000, "confidence": 0.95} Defensive patterns
Strategy: validation
Validate before calling
for (const [i, c] of parsed.entries()) {
const conf = (c as any).confidence;
if (typeof conf === 'number' && (conf < 0 || conf > 1)) {
throw new Error(`captions[${i}].confidence must be between 0 and 1`);
}
} Type guard
const isUnitInterval = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 1;
Try / catch
try {
const captions = parseCaptionFile({fileName, contents});
} catch (e) {
// divide percentages by 100 and retry
} Prevention
- Convert 0-100 percentage confidences to 0-1 before export
- Clamp confidence with Math.min(1, Math.max(0, value))
- Document the expected 0..1 scale in your export tooling
When it happens
Trigger: captions[i].confidence is 95 (a percentage) or 1.5 — the parse succeeded as a number but fails the 0..1 range check.
Common situations: ASR exports using 0-100 percentage scale; multiplying a probability twice; manual entry of percent values.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Expected a Remotion Caption[] JSON array.
- ${path} must be an object.
- ${path}.text must be a string.
- ${path}.startMs must be a finite, non-negative number.
- ${path}.endMs must be a finite, non-negative number.
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/70376004b9f235d9.
Report an issue: GitHub.