remotion-dev/remotion · error · Error

Expected cluster

Error message

Expected cluster

What it means

The resolved Segment box has no Cluster child (segment.value.find(type==='Cluster') returned undefined). This means a Cluster offset was recorded but the in-memory Segment tree does not yet contain a Cluster node, i.e. state and structure are out of sync.

Source

Thrown at packages/media-parser/src/containers/webm/parse-webm-header.ts:55

	if (isInsideCluster) {
		if (maySkipVideoData({state})) {
			return makeSkip(
				Math.min(
					state.contentLength,
					isInsideCluster.size + isInsideCluster.start,
				),
			);
		}

		const segments = structure.boxes.filter((box) => box.type === 'Segment');
		const segment = segments[isInsideCluster.segment];
		if (!segment) {
			throw new Error('Expected segment');
		}

		const clusters = segment.value.find((box) => box.type === 'Cluster');
		if (!clusters) {
			throw new Error('Expected cluster');
		}

		// let's not add it to the cluster
		if (results.type !== 'Block' && results.type !== 'SimpleBlock') {
			clusters.value.push(results);
		}
	} else if (isInsideSegment) {
		const segments = structure.boxes.filter((box) => box.type === 'Segment');
		const segment = segments[isInsideSegment.index];
		if (!segment) {
			throw new Error('Expected segment');
		}

		segment.value.push(results);
	} else {
		structure.boxes.push(results);
	}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-mux with ffmpeg to normalize Cluster placement.
  2. Disable seeking and parse start-to-end.
  3. Obtain a fresh source file.
  4. Use Mediabunny.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await parseMedia({src: 'in.mkv', fields: {durationInSeconds: true}});
} catch (err) {
  if (err instanceof Error && err.message === 'Expected cluster') {
    throw new Error('Cluster missing from Segment tree; re-mux the file.', {cause: err});
  }
  throw err;
}

Prevention

When it happens

Trigger: Cluster registration happened but the Cluster node was never appended to its Segment (parse order anomaly), or the Segment's children were lost during a seek/backtrack. Reachable with malformed files that interleave Cluster and Segment markers unexpectedly.

Common situations: Non-standard muxer output, files edited at the binary level, or seek-induced state desync.

Related errors


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