{"record":{"id":"af3f08bcbb0139ed","repo":"remotion-dev/remotion","slug":"expected-0-bytes-bytesremaining","errorCode":null,"errorMessage":"expected 0 bytes ${bytesRemaining}","messagePattern":"expected 0 bytes (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/iso-base-media/moov/mvhd.ts","lineNumber":108,"sourceCode":"\t\titerator.getFixedPointSigned1616Number(),\n\t\titerator.getFixedPointSigned1616Number(),\n\t\titerator.getFixedPointSigned230Number(),\n\t\titerator.getFixedPointSigned1616Number(),\n\t\titerator.getFixedPointSigned1616Number(),\n\t\titerator.getFixedPointSigned230Number(),\n\t];\n\n\t// pre-defined\n\titerator.discard(4 * 6);\n\n\t// next track id\n\tconst nextTrackId = iterator.getUint32();\n\n\tvolumeView.destroy();\n\n\tconst bytesRemaining = size - (iterator.counter.getOffset() - offset);\n\tif (bytesRemaining !== 0) {\n\t\tthrow new Error('expected 0 bytes ' + bytesRemaining);\n\t}\n\n\treturn {\n\t\tcreationTime: toUnixTimestamp(Number(creationTime)),\n\t\tmodificationTime: toUnixTimestamp(Number(modificationTime)),\n\t\ttimeScale,\n\t\tdurationInUnits: Number(durationInUnits),\n\t\tdurationInSeconds,\n\t\trate,\n\t\tvolume,\n\t\tmatrix: matrix as ThreeDMatrix,\n\t\tnextTrackId,\n\t\ttype: 'mvhd-box',\n\t\tboxSize: size,\n\t\toffset,\n\t};\n};\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/moov/mvhd.ts#L90-L126","documentation":"Thrown at the end of parseMvhd() (movie header box). After reading every defined mvhd field for its version, leftover bytes remain: size - (bytesConsumed) !== 0. The declared mvhd size does not match the spec-mandated field layout, so the parser treats the box as malformed and aborts.","triggerScenarios":"parseMedia({src}) on an MP4/MOV whose mvhd box size is inconsistent with its version-0 or version-1 layout — e.g. trailing padding bytes, a wrong size field, or a version the parser did not fully account for. Since mvhd carries the movie timescale, this also blocks all track registration.","commonSituations":"Files produced by non-compliant muxers that pad boxes incorrectly; hand-edited or patched MP4s; corrupted downloads where the mvhd size field is wrong.","solutions":["Re-mux with a compliant tool: ffmpeg -i in.mp4 -c copy out.mp4 (rebuilds mvhd with correct size).","Validate with MP4Box -info in.mp4 or ffprobe; both flag box-size inconsistencies.","Re-fetch the source if you suspect transfer corruption.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"exampleFix":"// before\nconst {durationInSeconds} = await parseMedia({src, reader: nodeReader});\n\n// after\ntry {\n  const r = await parseMedia({src, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /expected 0 bytes/.test(err.message)) {\n    // mvhd size mismatch — re-mux to rebuild the box\n  } else throw err;\n}","handlingStrategy":"try-catch","validationCode":"// Validate box integrity before parsing:\n//   MP4Box -info in.mp4   (flags box-size mismatches)\n//   ffprobe -v warning in.mp4\nimport {execFileSync} from 'node:child_process';\nfunction fileLooksIntact(file: string): boolean {\n  try {\n    execFileSync('ffprobe', ['-v','warning','-hide_banner', file], {encoding:'utf8', stdio:'pipe'});\n    return true;\n  } catch { return false; }\n}","typeGuard":"// mvhd size correctness is a deep binary property; not caller-type-guardable.\n// => typeGuard: null","tryCatchPattern":"try {\n  const {durationInSeconds} = await parseMedia({src, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /expected 0 bytes/.test(err.message)) {\n    // mvhd size mismatch — re-mux to rebuild the box\n  } else {\n    throw err;\n  }\n}","preventionTips":["Re-mux suspect files with ffmpeg to rebuild correctly-sized mvhd boxes.","Validate with MP4Box -info / ffprobe before parsing.","Re-fetch sources suspected of corruption.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"tags":["mp4","iso-base-media","media-parser","mvhd","corrupt-file","box-size"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}