{"record":{"id":"6dc0ca533b2830ed","repo":"remotion-dev/remotion","slug":"read-too-many-bytes-size-size-read-itera","errorCode":null,"errorMessage":"read too many bytes - size: ${size}, read: ${iterator.counter.getOffset() - initial}. initial offset: ${initial}","messagePattern":"read too many bytes - size: (.+?), read: (.+?)\\. initial offset: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/iso-base-media/get-children.ts","lineNumber":39,"sourceCode":"\tconst initial = iterator.counter.getOffset();\n\n\twhile (iterator.counter.getOffset() < size + initial) {\n\t\tconst parsed = await processBox({\n\t\t\titerator,\n\t\t\tlogLevel,\n\t\t\tonlyIfMoovAtomExpected,\n\t\t\tonlyIfMdatAtomExpected: null,\n\t\t\tcontentLength,\n\t\t});\n\t\tif (parsed.type !== 'box') {\n\t\t\tthrow new Error('Expected box');\n\t\t}\n\n\t\tboxes.push(parsed.box);\n\t}\n\n\tif (iterator.counter.getOffset() > size + initial) {\n\t\tthrow new Error(\n\t\t\t`read too many bytes - size: ${size}, read: ${iterator.counter.getOffset() - initial}. initial offset: ${initial}`,\n\t\t);\n\t}\n\n\treturn boxes;\n};\n","sourceCodeStart":21,"sourceCodeEnd":46,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/get-children.ts#L21-L46","documentation":"Thrown by getIsoBaseMediaChildren after the child-parsing loop when iterator.counter.getOffset() exceeds the parent box's declared size (size + initial offset). This means one of the child box parsers consumed more bytes than the parent said it should contain — a structural inconsistency. The error message includes the declared size, the bytes actually consumed, and the entry offset to aid diagnosis.","triggerScenarios":"A child box reports a size that, when consumed, overshoots the parent's declared size. Causes: corrupt size fields in either parent or child, a parser that over-reads a sub-box, a 64-bit vs 32-bit size confusion (largesize), or a buffer that contains bytes from the next sibling parsed as part of the current child.","commonSituations":"Files edited/hex-patched incorrectly. Muxers with off-by-one or alignment bugs. Streams where a content-length mismatch causes the parser to over-consume. Version regressions in the media-parser box readers.","solutions":["Re-mux with ffmpeg to rebuild correct box sizes: `ffmpeg -i in.mp4 -c copy -movflags faststart out.mp4`.","Inspect the failing file with `mp4dump` or `ffprobe -show_format` to find the malformed box.","If you control the parser feed, double-check that contentLength passed to getIsoBaseMediaChildren matches the real byte count.","Report a media-parser issue including the size/read/offset values from the error message."],"exampleFix":"// before\nconst boxes = await getIsoBaseMediaChildren({ size, iterator, logLevel, onlyIfMoovAtomExpected, contentLength });\n\n// after\ntry {\n  const boxes = await getIsoBaseMediaChildren({ size, iterator, logLevel, onlyIfMoovAtomExpected, contentLength });\n} catch (err) {\n  if (/read too many bytes/.test(String(err?.message))) {\n    throw new Error('MP4 box size header is inconsistent with its contents. The file is corrupt; re-mux it with ffmpeg.');\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"// Use mp4dump or ffprobe to detect inconsistent box sizes before deep parsing\nimport {execFileSync} from 'node:child_process';\nfunction boxSizesAreConsistent(file: string): boolean {\n  try {\n    execFileSync('mp4dump', [file], {encoding: 'utf8'});\n    return true;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const boxes = await getIsoBaseMediaChildren({ size, iterator, logLevel, onlyIfMoovAtomExpected, contentLength });\n} catch (err) {\n  if (/read too many bytes/.test(String(err?.message))) {\n    throw new Error('MP4 box sizes are internally inconsistent. The file is corrupt; re-mux it.');\n  }\n  throw err;\n}","preventionTips":["Treat 'read too many bytes' as definitive corruption and discard the asset.","Verify your readerInterface returns exactly the requested byte range.","Re-mux user uploads with ffmpeg as a normalization step.","Capture the size/read/offset values from the error for bug reports."],"tags":["mp4","isobmiff","media-parser","corrupt-file","box-size"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}