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

  1. Clamp the value to a minimum of 0: trimBefore={Math.max(0, computed)}.
  2. Fix the sign/logic error in the offset calculation.
  3. 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

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


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/62f01845f82373d5. Report an issue: GitHub.