diff --git a/src/isobmff/isobmff-demuxer.ts b/src/isobmff/isobmff-demuxer.ts index d73e97d..f6a4b36 100644 --- a/src/isobmff/isobmff-demuxer.ts +++ b/src/isobmff/isobmff-demuxer.ts @@ -392,7 +392,7 @@ export class IsobmffDemuxer extends Demuxer { // If they're not defined, we can simply use the decode timestamps as presentation timestamps } - return internalTrack.sampleTable; + return sampleTable; } async readFragment(): Promise { @@ -2239,7 +2239,8 @@ const getSampleIndexForTimestamp = (sampleTable: SampleTable, timescaleUnits: nu } 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); } }; diff --git a/todo.txt b/todo.txt index 2ed9e18..84501e1 100644 --- a/todo.txt +++ b/todo.txt @@ -3,4 +3,5 @@ - Add the new audio codecs to muxers - Mov muxer!!! Only mov can hold PCM audio, MP4 cannot - Metadata methods for computing average fps and bitrate -- A stream source?? Or like a callback-driven source \ No newline at end of file +- A stream source?? Or like a callback-driven source +- onRead callback for Source \ No newline at end of file