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 f0a9bf3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/demux/tsdemuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f0a9bf3

Please sign in to comment.