remotion-dev/remotion · error · TypeError
trimBefore must be greater than equal to 0 instead got ${tri
Error message
trimBefore must be greater than equal to 0 instead got ${trimBefore}. What it means
trimBefore represents a frame offset into the media, so it cannot be negative — there is no frame before 0. validateTrimProps rejects negative numbers to prevent seeking to an invalid position.
Source
Thrown at packages/core/src/validate-start-from-props.ts:62
};
export const validateTrimProps = (
trimBefore: number | undefined,
trimAfter: number | undefined,
) => {
if (typeof trimBefore !== 'undefined') {
if (typeof trimBefore !== 'number') {
throw new TypeError(
`type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`,
);
}
if (isNaN(trimBefore) || trimBefore === Infinity) {
throw new TypeError('trimBefore prop can not be NaN or Infinity.');
}
if (trimBefore < 0) {
throw new TypeError(
`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`,
);
}
}
if (typeof trimAfter !== 'undefined') {
if (typeof trimAfter !== 'number') {
throw new TypeError(
`type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`,
);
}
if (isNaN(trimAfter)) {
throw new TypeError('trimAfter prop can not be NaN.');
}
if (trimAfter <= 0) {
throw new TypeError(View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Clamp the value to a minimum of 0: trimBefore={Math.max(0, computed)}.
- Fix the sign/logic error in the offset calculation.
- If the intent is to delay the media rather than trim it, use a <Sequence> with a positive `from` instead.
Example fix
// before
<Video src={src} trimBefore={offset - 30} />
// after
<Video src={src} trimBefore={Math.max(0, offset - 30)} /> Defensive patterns
Strategy: validation
Validate before calling
if (trimBefore !== undefined && trimBefore < 0) {
throw new Error('trimBefore must be >= 0');
} Type guard
const isValidTrimBefore = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v) && v >= 0;
Prevention
- Clamp dynamic offsets with Math.max(0, value) before passing.
- Use a <Sequence> with a positive `from` when the intent is to delay, not trim.
- Double-check sign conventions in relative-offset math.
When it happens
Trigger: Passing trimBefore with a negative value (trimBefore={-10}), or a computed expression that goes negative (e.g. trimBefore={offset - margin} where margin exceeds offset).
Common situations: Subtracting a padding constant from a dynamic offset without clamping; sign errors in relative-offset math; passing a value derived from a timestamp that can be negative for early frames.
Related errors
- startFrom must be greater than equal to 0 instead got ${star
- endAt must be a positive number, instead got ${endAt}.
- endAt prop must be greater than startFrom prop.
- trimAfter must be a positive number, instead got ${trimAfter
- trimAfter prop must be greater than trimBefore prop.
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/62f01845f82373d5.
Report an issue: GitHub.