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
- Re-mux with ffmpeg to normalize Cluster placement.
- Disable seeking and parse start-to-end.
- Obtain a fresh source file.
- 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
- Re-mux uploads to normalize Cluster placement.
- Prefer linear parse over seek-based fields on non-trusted files.
- Maintain a fallback source.
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
- Expected segment
- Expected to be inside segment
- Could not find sample rate or number of channels
- Expected block segment
- Expected CuePoint
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/3cfcdd1ecf3ff53c.
Report an issue: GitHub.