{"record":{"id":"e35a1a6b3a1faac0","repo":"remotion-dev/remotion","slug":"expected-numberofentries-sample-descriptions-g","errorCode":null,"errorMessage":"Expected ${numberOfEntries} sample descriptions, got ${boxes.length}","messagePattern":"Expected (.+?) sample descriptions, got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/iso-base-media/stsd/stsd.ts","lineNumber":46,"sourceCode":"\t\tthrow new Error(`Unsupported STSD version ${version}`);\n\t}\n\n\t// flags, we discard them\n\titerator.discard(3);\n\n\tconst numberOfEntries = iterator.getUint32();\n\n\tconst bytesRemainingInBox = size - (iterator.counter.getOffset() - offset);\n\n\tconst boxes = await parseIsoFormatBoxes({\n\t\tmaxBytes: bytesRemainingInBox,\n\t\tlogLevel,\n\t\titerator,\n\t\tcontentLength,\n\t});\n\n\tif (boxes.length !== numberOfEntries) {\n\t\tthrow new Error(\n\t\t\t`Expected ${numberOfEntries} sample descriptions, got ${boxes.length}`,\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'stsd-box',\n\t\tboxSize: size,\n\t\toffset,\n\t\tnumberOfEntries,\n\t\tsamples: boxes,\n\t};\n};\n","sourceCodeStart":28,"sourceCodeEnd":59,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/stsd/stsd.ts#L28-L59","documentation":"The stsd box declares a numberOfEntries count, and after parsing child sample-entry boxes the actual parsed count must match. If they differ, either a child box failed to parse and was skipped, the box sizes are inconsistent, or the file is corrupt. This is a structural integrity check.","triggerScenarios":"parseStsd reads numberOfEntries, then parseIsoFormatBoxes returns a boxes array whose length differs. Common when a child sample entry has an inconsistent size causing it to be mis-parsed or skipped.","commonSituations":"Files with malformed sample entries, sizes that don't align, or where an unknown codec FourCC caused an inner parse to bail early.","solutions":["Inspect stsd children with `mp4box -dnal input.mp4` or a structural MP4 inspector (e.g. mp4dump).","Re-mux: `ffmpeg -i input.mp4 -c copy remuxed.mp4` to rebuild the stsd consistently.","Transcode to regenerate sample entries: `ffmpeg -i input.mp4 -c:v libx264 -c:a aac out.mp4`.","Report the file upstream if a standard codec's sample entry is being skipped."],"exampleFix":"// before: stsd declares 2 entries but only 1 parses due to bad child size\nffmpeg -i corrupt.mp4 -c copy remuxed.mp4\n// after: stsd entry count matches parsed count","handlingStrategy":"try-catch","validationCode":"// Verify stsd entry count matches parsed children with mp4dump before parsing\n// mp4dump input.mp4 | grep -A30 stsd → compare numberOfEntries to child box count","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src, fields: {dimensions: true}});\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Expected ') && err.message.includes('sample descriptions')) {\n    // structural mismatch; re-mux or transcode\n  } else throw err;\n}","preventionTips":["Re-mux with ffmpeg to rebuild the stsd consistently.","Transcode to fully regenerate sample entries if re-mux fails.","Validate with mp4dump for inputs from unreliable sources."],"tags":["media-parser","isobmff","stsd-box","corrupt-file","integrity-check","mp4"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}