Handle missing starting key sample in ISOBMFF

This commit is contained in:
Vanilagy
2025-08-12 09:29:57 +02:00
parent c9dcebed6f
commit e0a4169bf8
2 changed files with 15 additions and 9 deletions
+6
View File
@@ -1459,6 +1459,12 @@ export class IsobmffDemuxer extends Demuxer {
const sampleIndex = this.metadataReader.readU32() - 1; // Convert to 0-indexed
track.sampleTable.keySampleIndices.push(sampleIndex);
}
if (track.sampleTable.keySampleIndices[0] !== 0) {
// Some files don't mark the first sample a key sample, which is basically almost always incorrect.
// Here, we correct for that mistake:
track.sampleTable.keySampleIndices.unshift(0);
}
}; break;
case 'stsc': {