{"record":{"id":"7028167f5207a34d","repo":"remotion-dev/remotion","slug":"expected-sampledescriptionindex-to-be-1-but-got","errorCode":null,"errorMessage":"Expected sampleDescriptionIndex to be 1, but got ${sampleDescriptionIndex}","messagePattern":"Expected sampleDescriptionIndex to be 1, but got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/media-parser/src/containers/iso-base-media/stsd/stsc.ts","lineNumber":37,"sourceCode":"\toffset: number;\n\tsize: number;\n}): StscBox => {\n\tconst version = iterator.getUint8();\n\tif (version !== 0) {\n\t\tthrow new Error(`Unsupported STSD version ${version}`);\n\t}\n\n\tconst flags = iterator.getSlice(3);\n\tconst entryCount = iterator.getUint32();\n\n\tconst entries: Map<number, number> = new Map();\n\n\tfor (let i = 0; i < entryCount; i++) {\n\t\tconst firstChunk = iterator.getUint32();\n\t\tconst samplesPerChunk = iterator.getUint32();\n\t\tconst sampleDescriptionIndex = iterator.getUint32();\n\t\tif (sampleDescriptionIndex !== 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected sampleDescriptionIndex to be 1, but got ${sampleDescriptionIndex}`,\n\t\t\t);\n\t\t}\n\n\t\tentries.set(firstChunk, samplesPerChunk);\n\t}\n\n\treturn {\n\t\ttype: 'stsc-box',\n\t\tboxSize: size,\n\t\toffset,\n\t\tversion,\n\t\tflags: [...flags],\n\t\tentryCount,\n\t\tentries,\n\t};\n};\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/stsd/stsc.ts#L19-L55","documentation":"The STSC parser only accepts entries whose sampleDescriptionIndex equals 1. The spec permits multiple sample descriptions, but this parser assumes a single description per track and throws when sampleDescriptionIndex != 1. This is a real parser limitation, not necessarily corruption.","triggerScenarios":"An stsc entry has sampleDescriptionIndex other than 1. This happens in MP4 files that legitimately contain multiple sample entries (e.g. layered codecs, scalable streams, or some adaptive content) where chunks reference different descriptions.","commonSituations":"Files with multiple sample entries in stsd (rare but valid), some encrypted/DRM content with multiple description indices, or files produced by specialized broadcast encoders.","solutions":["Inspect stsc entries: `mp4box -dts input.mp4` or use a hex inspector on the stsc box to see the sampleDescriptionIndex values.","Re-mux with a single sample description: `ffmpeg -i input.mp4 -c copy -movflags +faststart remuxed.mp4`.","If the multi-description layout is intentional (e.g. scalable video), this file is not supported by the current parser — report upstream.","Transcode to collapse to a single description: `ffmpeg -i input.mp4 -c:v libx264 ... out.mp4`."],"exampleFix":"// before: multi-description stsc entries throw\nffmpeg -i input.mp4 -c:v libx264 -c:a aac single_desc.mp4\n// after: remuxed with sampleDescriptionIndex=1","handlingStrategy":"validation","validationCode":"// Inspect stsc entries with mp4dump before parsing\n// mp4dump input.mp4 | grep -A20 stsc → check sample_description_index values\n// If any != 1, re-mux with ffmpeg -map 0:v -map 0:a -c copy to collapse descriptions","typeGuard":"function hasSingleSampleDescription(entries: Array<{sampleDescriptionIndex: number}>): boolean {\n  return entries.every((e) => e.sampleDescriptionIndex === 1);\n}","tryCatchPattern":"try {\n  await parseMedia({src, fields: {dimensions: true}});\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Expected sampleDescriptionIndex to be 1')) {\n    // multi-description file; transcode to single description\n  } else throw err;\n}","preventionTips":["Avoid producing files with multiple sample descriptions if you control encoding.","For scalable/multi-layer content, transcode to a single-layer codec before parsing.","Pre-inspect stsc with mp4dump for inputs from untrusted sources."],"tags":["media-parser","isobmff","stsc-box","parser-coverage","mp4"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}