From 1feb5a23e8132dbb8c41a0118ad6b1aca6b45c34 Mon Sep 17 00:00:00 2001 From: xqq Date: Thu, 28 Dec 2017 17:32:22 +0900 Subject: [PATCH] MP4Remuxer: Not process if only one sample existed to avoid guessing sample duration --- src/remux/mp4-remuxer.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/remux/mp4-remuxer.js b/src/remux/mp4-remuxer.js index 571bf3c0..aaffcf58 100644 --- a/src/remux/mp4-remuxer.js +++ b/src/remux/mp4-remuxer.js @@ -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; } @@ -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; @@ -529,7 +535,7 @@ class MP4Remuxer { this._onMediaSegment('audio', segment); } - _remuxVideo(videoTrack) { + _remuxVideo(videoTrack, force) { if (this._videoMeta == null) { return; } @@ -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;