remotion-dev/remotion · error · TypeError

durationInFrames must be an integer between 1 and ${MAX_DURA

Error message

durationInFrames must be an integer between 1 and ${MAX_DURATION_IN_FRAMES}

What it means

makeCompositionDragData validates durationInFrames before encoding it. When provided, it must be an integer >= 1 and <= MAX_DURATION_IN_FRAMES; non-integers, zero, negatives, and excessive values throw this TypeError. Duration is optional (null allowed) but must be exact when present because it is serialized as an integer in the drag MIME string.

Source

Thrown at packages/studio/src/components/composition-drag-data.ts:214

		);
	}

	if (
		height !== null &&
		(!Number.isFinite(height) || height <= 0 || height > MAX_DIMENSION)
	) {
		throw new TypeError(
			`width and height must be numbers between 0 and ${MAX_DIMENSION}`,
		);
	}

	if (
		durationInFrames !== null &&
		(!Number.isInteger(durationInFrames) ||
			durationInFrames <= 0 ||
			durationInFrames > MAX_DURATION_IN_FRAMES)
	) {
		throw new TypeError(
			`durationInFrames must be an integer between 1 and ${MAX_DURATION_IN_FRAMES}`,
		);
	}

	const data: CompositionDragData = {
		type: 'remotion-composition',
		version: 1,
		compositionFile,
		compositionId,
	};
	const segments = [
		REMOTION_DRAG_MIME_TYPE,
		`v=${DRAG_MIME_VERSION}`,
		'type=composition',
	];
	if (width !== null && height !== null) {
		segments.push(`width=${width}`, `height=${height}`);
	}

View on GitHub (pinned to a6a7485a9a)

Solutions

  1. Ensure the value is an integer: Math.round(comp.durationInFrames) before passing
  2. If duration is unknown, pass null instead of a guessed number
  3. Clamp to [1, MAX_DURATION_IN_FRAMES] before calling
  4. Fix the source: read durationInFrames directly from the resolved composition rather than deriving it

Example fix

// before
makeCompositionDragData({..., durationInFrames: comp.durationInFrames / fps * fps})
// after
const d = comp.durationInFrames;
const valid = Number.isInteger(d) && d > 0 && d <= MAX_DURATION_IN_FRAMES;
makeCompositionDragData({..., durationInFrames: valid ? d : null})
Defensive patterns

Strategy: validation

Validate before calling

const d = comp.durationInFrames;
const validDuration = Number.isInteger(d) && d > 0 && d <= MAX_DURATION_IN_FRAMES ? d : null;

Type guard

const isValidDuration = (n: number | null): n is number =>
  n !== null && Number.isInteger(n) && n > 0 && n <= MAX_DURATION_IN_FRAMES;

Try / catch

try {
  return makeCompositionDragData({..., durationInFrames: rawDuration});
} catch (err) {
  if (err instanceof TypeError && err.message.includes('durationInFrames')) {
    return makeCompositionDragData({..., durationInFrames: null});
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling makeCompositionDragData with durationInFrames that is fractional (e.g. from frame math with interpolation), <= 0, or exceeding MAX_DURATION_IN_FRAMES.

Common situations: durationInFrames computed via division/averaging producing 2.5; a composition with durationInFrames still undefined coerced to NaN; copy/paste of durations from other units (seconds vs frames); huge values from unbounded calculations.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@a6a7485a9a (2026-09-02). Data as JSON: /api/errors/bd92317282521af4. Report an issue: GitHub.