Fix sample index retrieval case

This commit is contained in:
Vanilagy
2025-01-02 23:44:40 +01:00
parent a3f19f6f08
commit 8db8f10a1e
2 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -392,7 +392,7 @@ export class IsobmffDemuxer extends Demuxer {
// If they're not defined, we can simply use the decode timestamps as presentation timestamps // If they're not defined, we can simply use the decode timestamps as presentation timestamps
} }
return internalTrack.sampleTable; return sampleTable;
} }
async readFragment(): Promise<Fragment> { async readFragment(): Promise<Fragment> {
@@ -2239,7 +2239,8 @@ const getSampleIndexForTimestamp = (sampleTable: SampleTable, timescaleUnits: nu
} }
const entry = sampleTable.sampleTimingEntries[index]!; const entry = sampleTable.sampleTimingEntries[index]!;
return entry.startIndex + Math.floor((timescaleUnits - entry.startDecodeTimestamp) / entry.delta); return entry.startIndex
+ Math.min(Math.floor((timescaleUnits - entry.startDecodeTimestamp) / entry.delta), entry.count - 1);
} }
}; };
+2 -1
View File
@@ -3,4 +3,5 @@
- Add the new audio codecs to muxers - Add the new audio codecs to muxers
- Mov muxer!!! Only mov can hold PCM audio, MP4 cannot - Mov muxer!!! Only mov can hold PCM audio, MP4 cannot
- Metadata methods for computing average fps and bitrate - Metadata methods for computing average fps and bitrate
- A stream source?? Or like a callback-driven source - A stream source?? Or like a callback-driven source
- onRead callback for Source