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 7e6f6ed commit 57c78c9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/demux/tsdemuxer.js
Expand Up @@ -1036,17 +1036,19 @@ 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++;
} else {
// logger.log('Unable to parse AAC frame');
break;
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++;
continue;
}
}
// We are at an ADTS header, but do not have enough data for a frame
// Remaining data will be added to aacOverFlow
break;
} else {
// nothing found, keep looking
offset++;
Expand Down

0 comments on commit 57c78c9

Please sign in to comment.