diff --git a/src/demux/tsdemuxer.ts b/src/demux/tsdemuxer.ts index 8add100249d..ab2d9a73516 100644 --- a/src/demux/tsdemuxer.ts +++ b/src/demux/tsdemuxer.ts @@ -111,7 +111,14 @@ class TSDemuxer implements Demuxer { if (!foundPat && parsePID(data, j) === 0) { foundPat = true; } - if (foundPat && j + PACKET_LENGTH > scanwindow) { + if (foundPat && data[j + PACKET_LENGTH] === 0x47) { + // If length supports 3 packets, confirm + if ( + length > j + PACKET_LENGTH * 2 && + data[j + PACKET_LENGTH * 2] !== 0x47 + ) { + return -1; + } return i; } } else {