Skip to content

Commit

Permalink
Fix issue in TS Demuxer that skipped AAC frames at the end of PES pac…
Browse files Browse the repository at this point in the history
…kets

Fixes #2528
  • Loading branch information
Rob Walch committed Feb 25, 2020
1 parent 12f2e16 commit 7ea3566
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/demux/tsdemuxer.js
Expand Up @@ -1036,15 +1036,21 @@ class TSDemuxer {

// scan for aac samples
while (offset < len) {
if (ADTS.isHeader(data, offset) && (offset + 5) < len) {
let frame = ADTS.appendFrame(track, data, offset, pts, frameIndex);
if (frame) {
// logger.log(`${Math.round(frame.sample.pts)} : AAC`);
offset += frame.length;
stamp = frame.sample.pts;
frameIndex++;
if (ADTS.isHeader(data, offset)) {
if ((offset + 5) < len) {
const frame = ADTS.appendFrame(track, data, offset, pts, frameIndex);
if (frame) {
offset += frame.length;
stamp = frame.sample.pts;
frameIndex++;
} else {
// We are at an ADTS header, but could not extract a complete frame
// Remaining data will be added to aacOverFlow
break;
}
} else {
// logger.log('Unable to parse AAC frame');
// We are at an ADTS header, but do not have enough data for a frame
// Remaining data will be added to aacOverFlow
break;
}
} else {
Expand Down

0 comments on commit 7ea3566

Please sign in to comment.