Skip to content

Commit

Permalink
Fix TS probing by requiring 2-3 packet start bytes to be matched
Browse files Browse the repository at this point in the history
Fixes #5501
  • Loading branch information
robwalch committed May 24, 2023
1 parent a58ce98 commit c969f6c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/demux/tsdemuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@ class TSDemuxer implements Demuxer {
if (!foundPat && parsePID(data, j) === 0) {
foundPat = true;
}
if (foundPat && j + PACKET_LENGTH > scanwindow) {
if (
foundPat &&
j + PACKET_LENGTH > scanwindow &&
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 {
Expand Down

0 comments on commit c969f6c

Please sign in to comment.