Skip to content

Commit

Permalink
Merge pull request #4481 from albertdaurell/feature/report_one_frag_p…
Browse files Browse the repository at this point in the history
…arsing_error_per_ts

Report only 1 FRAG_PARSING_ERROR per parsed TS file
  • Loading branch information
robwalch committed Jan 13, 2022
2 parents 6c7a549 + 4c11ae0 commit 5bfe0d9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/demux/tsdemuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ class TSDemuxer implements Demuxer {
}

// loop through TS packets
let tsPacketErrors = 0;
for (let start = syncOffset; start < len; start += 188) {
if (data[start] === 0x47) {
const stt = !!(data[start + 1] & 0x40);
Expand Down Expand Up @@ -391,15 +392,19 @@ class TSDemuxer implements Demuxer {
break;
}
} else {
this.observer.emit(Events.ERROR, Events.ERROR, {
type: ErrorTypes.MEDIA_ERROR,
details: ErrorDetails.FRAG_PARSING_ERROR,
fatal: false,
reason: 'TS packet did not start with 0x47',
});
tsPacketErrors++;
}
}

if (tsPacketErrors > 0) {
this.observer.emit(Events.ERROR, Events.ERROR, {
type: ErrorTypes.MEDIA_ERROR,
details: ErrorDetails.FRAG_PARSING_ERROR,
fatal: false,
reason: `Found ${tsPacketErrors} TS packet/s that do not start with 0x47`,
});
}

avcTrack.pesData = avcData;
audioTrack.pesData = audioData;
id3Track.pesData = id3Data;
Expand Down

0 comments on commit 5bfe0d9

Please sign in to comment.