remotion-dev/remotion · error · Error
Expected block segment
Error message
Expected block segment
What it means
While post-processing a BlockGroup, the parser looks for a SimpleBlock or Block child and throws if none (or a non-block child matched) is found. Per the Matroska spec a BlockGroup must contain a Block, so this indicates a malformed BlockGroup element.
Source
Thrown at packages/media-parser/src/containers/webm/parse-ebml.ts:278
return {
type: 'Block',
value: new Uint8Array([]),
minVintWidth: ebml.minVintWidth,
};
}
}
if (ebml.type === 'BlockGroup') {
// Blocks don't have information about keyframes.
// https://ffmpeg.org/pipermail/ffmpeg-devel/2015-June/173825.html
// "For Blocks, keyframes is
// inferred by the absence of ReferenceBlock element (as done by matroskadec).""
const block = ebml.value.find(
(c) => c.type === 'SimpleBlock' || c.type === 'Block',
);
if (!block || (block.type !== 'SimpleBlock' && block.type !== 'Block')) {
throw new Error('Expected block segment');
}
const hasReferenceBlock = ebml.value.find(
(c) => c.type === 'ReferenceBlock',
);
const sample =
block.value.length === 0
? null
: await getSampleFromBlock({
ebml: block,
webmState,
offset,
structureState,
callbacks,
logLevel,
onVideoTrack,
avcState,View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Re-mux the file ('ffmpeg -i in.mkv -c copy out.mkv') to reconstruct valid BlockGroups.
- Validate with ffprobe; if it errors on the same region, the file is damaged.
- Use a different source file.
- Try Mediabunny as an alternate parser.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await parseMedia({src: 'in.mkv', fields: {samples: true}});
} catch (err) {
if (err instanceof Error && /Expected block segment/.test(err.message)) {
throw new Error('Malformed BlockGroup in source; re-mux with ffmpeg.', {cause: err});
}
throw err;
} Prevention
- Re-mux user uploads with ffmpeg before parsing.
- Validate files with ffprobe/MediaInfo first.
- Keep a fallback source URL for re-fetch on parse failure.
When it happens
Trigger: A BlockGroup element whose children are only ReferenceBlock/BlockAdditions/etc. with no actual Block/SimpleBlock; a partial BlockGroup cut by truncation; corruption that renamed the child element ID.
Common situations: Damaged MKV files, files produced by non-conformant muxers, or streams truncated inside a BlockGroup.
Related errors
- Could not find sample rate or number of channels
- Expected track entry segment
- Not enough bytes left to parse EBML - this should not happen
- Offset ${offsetNow - startOffset} is larger than the length
- Expected segment
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/cacb2b96cda31bb5.
Report an issue: GitHub.