Skip to content

Commit

Permalink
MP4Remuxer: Not process if only one sample existed to avoid guessing …
Browse files Browse the repository at this point in the history
…sample duration
  • Loading branch information
xqq committed Dec 28, 2017
1 parent 3d81d15 commit 1feb5a2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/remux/mp4-remuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ class MP4Remuxer {
this._videoStashedLastSample = null;
this._audioStashedLastSample = null;

this.remux(audioTrack, videoTrack);
this._remuxVideo(videoTrack, true);
this._remuxAudio(audioTrack, true);
}

_remuxAudio(audioTrack) {
_remuxAudio(audioTrack, force) {
if (this._audioMeta == null) {
return;
}
Expand All @@ -248,6 +249,11 @@ class MP4Remuxer {
if (!samples || samples.length === 0) {
return;
}
if (samples.length === 1 && !force) {
// If [sample count in current batch] === 1 && (force != true)
// Ignore and keep in demuxer's queue
return;
} // else if (force === true) do remux

let offset = 0;
let mdatbox = null;
Expand Down Expand Up @@ -529,7 +535,7 @@ class MP4Remuxer {
this._onMediaSegment('audio', segment);
}

_remuxVideo(videoTrack) {
_remuxVideo(videoTrack, force) {
if (this._videoMeta == null) {
return;
}
Expand All @@ -543,6 +549,11 @@ class MP4Remuxer {
if (!samples || samples.length === 0) {
return;
}
if (samples.length === 1 && !force) {
// If [sample count in current batch] === 1 && (force != true)
// Ignore and keep in demuxer's queue
return;
} // else if (force === true) do remux

let offset = 8;
let mdatbox = null;
Expand Down

0 comments on commit 1feb5a2

Please sign in to comment.