Skip to content

Commit

Permalink
Merge pull request #2530 from video-dev/bugfix/ts-pes-aac-overflow
Browse files Browse the repository at this point in the history
Improve PES ACC overflow handling
  • Loading branch information
robwalch committed Feb 26, 2020
2 parents 959482b + 57c78c9 commit 4f084c9
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 4f084c9

Please sign in to comment.