remotion-dev/remotion · error · TypeError

startFrom prop can not be NaN or Infinity.

Error message

startFrom prop can not be NaN or Infinity.

What it means

Even when startFrom is a number, validateStartFromProps rejects NaN and Infinity because neither represents a valid frame offset. NaN usually results from a failed Number() conversion or an arithmetic error; Infinity results from division by zero. Both would produce undefined playback behavior downstream.

Source

Thrown at packages/core/src/validate-start-from-props.ts:13

export const validateStartFromProps = (
	startFrom: number | undefined,
	endAt: number | undefined,
) => {
	if (typeof startFrom !== 'undefined') {
		if (typeof startFrom !== 'number') {
			throw new TypeError(
				`type of startFrom prop must be a number, instead got type ${typeof startFrom}.`,
			);
		}

		if (isNaN(startFrom) || startFrom === Infinity) {
			throw new TypeError('startFrom prop can not be NaN or Infinity.');
		}

		if (startFrom < 0) {
			throw new TypeError(
				`startFrom must be greater than equal to 0 instead got ${startFrom}.`,
			);
		}
	}

	if (typeof endAt !== 'undefined') {
		if (typeof endAt !== 'number') {
			throw new TypeError(
				`type of endAt prop must be a number, instead got type ${typeof endAt}.`,
			);
		}

		if (isNaN(endAt)) {
			throw new TypeError('endAt prop can not be NaN.');

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Validate the computed value with Number.isFinite() before passing it: startFrom={isFinite(v) ? v : undefined}.
  2. Fix the upstream parse: use Number(str) only after a regex/parseInt check, or default to 0.
  3. Switch to the non-deprecated trimBefore prop.
  4. Omit the prop when the dynamic value cannot be guaranteed finite.

Example fix

// before
const startFrom = Number(userInput); // may be NaN
<Video src={src} startFrom={startFrom} />
// after
const raw = Number(userInput);
const startFrom = Number.isFinite(raw) ? raw : undefined;
<Video src={src} trimBefore={startFrom} />
Defensive patterns

Strategy: validation

Validate before calling

if (startFrom !== undefined && !Number.isFinite(startFrom)) {
  throw new Error('startFrom must be a finite number');
}

Type guard

const isFiniteStartFrom = (v: unknown): v is number =>
  typeof v === 'number' && Number.isFinite(v) && v >= 0;

Prevention

When it happens

Trigger: Passing startFrom={NaN} (e.g. from Number('abc')), startFrom={Infinity} (e.g. from 1/0), or any expression that evaluates to NaN/Infinity.

Common situations: Parsing a user-supplied or CMS-supplied string with Number() that returns NaN; computing startFrom dynamically with division where the divisor can be zero; spreading props from an unvalidated external source.

Related errors


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