remotion-dev/remotion · error · Error
Offset ${offsetNow - startOffset} is larger than the length
Error message
Offset ${offsetNow - startOffset} is larger than the length of the hex ${size} What it means
While parsing the children of a container EBML element, the iterator's offset advanced past the parent's declared size (offsetNow - startOffset > size). This is a structural inconsistency: the sum of child element sizes does not fit inside the parent, so the EBML tree is corrupt.
Source
Thrown at packages/media-parser/src/containers/webm/parse-ebml.ts:142
const offset = iterator.counter.getOffset();
const value = await parseEbml(iterator, statesForProcessing, logLevel);
if (value) {
const remapped = statesForProcessing
? // eslint-disable-next-line @typescript-eslint/no-use-before-define
await postprocessEbml({
offset,
ebml: value,
statesForProcessing,
})
: value;
children.push(remapped);
}
const offsetNow = iterator.counter.getOffset();
if (offsetNow - startOffset > size) {
throw new Error(
`Offset ${offsetNow - startOffset} is larger than the length of the hex ${size}`,
);
}
if (offsetNow - startOffset === size) {
break;
}
}
return {type: hasInMap.name, value: children, minVintWidth};
}
// @ts-expect-error
throw new Error(`Unknown segment type ${hasInMap.type}`);
};
export const postprocessEbml = async ({
offset,View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Re-mux with ffmpeg ('ffmpeg -i in.mkv -c copy out.mkv') to rebuild correct EBML sizes.
- Open the file with ffprobe/MediaInfo; if they also report errors, the file is structurally damaged.
- Obtain a fresh copy of the source.
- Switch to Mediabunny for an alternative parse path.
Example fix
// before
await parseMedia({src: 'corrupt.mkv'}); // throws with 'Offset N is larger than the length of the hex M'
// after
// shell: ffmpeg -i corrupt.mkv -c copy remuxed.mkv
await parseMedia({src: 'remuxed.mkv'}); Defensive patterns
Strategy: try-catch
Validate before calling
// Structural integrity pre-check via ffprobe (returns non-zero on corrupt EBML).
import {execFileSync} from 'node:child_process';
function isStructurallyValid(file: string): boolean {
try {
execFileSync('ffprobe', ['-v', 'error', '-count_packets', file], {stdio: 'ignore'});
return true;
} catch { return false; }
}
if (!isStructurallyValid('in.mkv')) throw new Error('corrupt EBML structure'); Try / catch
try {
await parseMedia({src: 'in.mkv'});
} catch (err) {
if (err instanceof Error && /Offset .* is larger than the length of the hex/.test(err.message)) {
throw new Error('Corrupt EBML container sizes; re-mux with ffmpeg.', {cause: err});
}
throw err;
} Prevention
- Run ffprobe -count_packets on user-supplied files before parsing.
- Re-mux uploaded media through ffmpeg.
- Treat parseMedia failures on a file as a signal to obtain a fresh copy.
When it happens
Trigger: A corrupted or hand-edited Matroska file where a container's declared size is smaller than its actual children; a bit-flip in a size VInt; or a parser bug where a child consumed too many bytes. The message interpolates the overrun and the declared size for diagnosis.
Common situations: Files damaged in transfer/storage, files written by buggy muxers that mis-size containers, or partial overwrites.
Related errors
- Expected length of ${segmentId} to be greater or equal 0
- Expected track entry segment
- Could not find sample rate or number of channels
- Not enough bytes left to parse EBML - this should not happen
- Expected block segment
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/f95f8a50a28e67aa.
Report an issue: GitHub.