Skip to content

Commit 3cd67b3

Browse files
Dcatflyxqq
authored andcommitted
feat: skip tag which has error timestamp
1 parent 26d00d9 commit 3cd67b3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/demux/flv-demuxer.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class FLVDemuxer {
7979

8080
this._naluLengthSize = 4;
8181
this._timestampBase = 0; // int32, in milliseconds
82+
this._lastTimestamp = 0;
8283
this._timescale = 1000;
8384
this._duration = 0; // int32, in milliseconds
8485
this._durationOverrided = false;
@@ -121,6 +122,7 @@ class FLVDemuxer {
121122
this._videoMetadata = null;
122123
this._videoTrack = null;
123124
this._audioTrack = null;
125+
this._lastTimestamp = 0;
124126

125127
this._onError = null;
126128
this._onMediaInfo = null;
@@ -328,6 +330,14 @@ class FLVDemuxer {
328330

329331
let timestamp = ts0 | (ts1 << 8) | (ts2 << 16) | (ts3 << 24);
330332

333+
if (timestamp < this._lastTimestamp) {
334+
Log.w(this.TAG, `Current tag's timestamp(${timestamp}) is smaller than last timestamp(${this._lastTimestamp}), skipped`);
335+
// consume the whole tag (skip it)
336+
offset += 11 + dataSize + 4;
337+
continue;
338+
}
339+
this._lastTimestamp = timestamp;
340+
331341
let streamId = v.getUint32(7, !le) & 0x00FFFFFF;
332342
if (streamId !== 0) {
333343
Log.w(this.TAG, 'Meet tag which has StreamID != 0!');

0 commit comments

Comments
 (0)