{"record":{"id":"f95f8a50a28e67aa","repo":"remotion-dev/remotion","slug":"offset-offsetnow-startoffset-is-larger-than-t","errorCode":null,"errorMessage":"Offset ${offsetNow - startOffset} is larger than the length of the hex ${size}","messagePattern":"Offset (.+?) is larger than the length of the hex (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/webm/parse-ebml.ts","lineNumber":142,"sourceCode":"\t\t\tconst offset = iterator.counter.getOffset();\n\t\t\tconst value = await parseEbml(iterator, statesForProcessing, logLevel);\n\n\t\t\tif (value) {\n\t\t\t\tconst remapped = statesForProcessing\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-use-before-define\n\t\t\t\t\t\tawait postprocessEbml({\n\t\t\t\t\t\t\toffset,\n\t\t\t\t\t\t\tebml: value,\n\t\t\t\t\t\t\tstatesForProcessing,\n\t\t\t\t\t\t})\n\t\t\t\t\t: value;\n\t\t\t\tchildren.push(remapped);\n\t\t\t}\n\n\t\t\tconst offsetNow = iterator.counter.getOffset();\n\n\t\t\tif (offsetNow - startOffset > size) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Offset ${offsetNow - startOffset} is larger than the length of the hex ${size}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (offsetNow - startOffset === size) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn {type: hasInMap.name, value: children, minVintWidth};\n\t}\n\n\t// @ts-expect-error\n\tthrow new Error(`Unknown segment type ${hasInMap.type}`);\n};\n\nexport const postprocessEbml = async ({\n\toffset,","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/webm/parse-ebml.ts#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"Files damaged in transfer/storage, files written by buggy muxers that mis-size containers, or partial overwrites.","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."],"exampleFix":"// before\nawait parseMedia({src: 'corrupt.mkv'}); // throws with 'Offset N is larger than the length of the hex M'\n\n// after\n// shell: ffmpeg -i corrupt.mkv -c copy remuxed.mkv\nawait parseMedia({src: 'remuxed.mkv'});","handlingStrategy":"try-catch","validationCode":"// Structural integrity pre-check via ffprobe (returns non-zero on corrupt EBML).\nimport {execFileSync} from 'node:child_process';\nfunction isStructurallyValid(file: string): boolean {\n  try {\n    execFileSync('ffprobe', ['-v', 'error', '-count_packets', file], {stdio: 'ignore'});\n    return true;\n  } catch { return false; }\n}\nif (!isStructurallyValid('in.mkv')) throw new Error('corrupt EBML structure');","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src: 'in.mkv'});\n} catch (err) {\n  if (err instanceof Error && /Offset .* is larger than the length of the hex/.test(err.message)) {\n    throw new Error('Corrupt EBML container sizes; re-mux with ffmpeg.', {cause: err});\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["webm","matroska","ebml","media-parser","corruption","container-size"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}