From a20f1db194539d43e6851f54f28378c33f98d1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 31 Aug 2023 10:12:07 +0200 Subject: [PATCH] fix: Fix Mp4Generator (#5566) Fixes the mvex generation Removes width and height from tkhd box for audio tracks --- lib/util/mp4_generator.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/util/mp4_generator.js b/lib/util/mp4_generator.js index 6d248865fc..aca9d754d1 100644 --- a/lib/util/mp4_generator.js +++ b/lib/util/mp4_generator.js @@ -55,7 +55,7 @@ shaka.util.Mp4Generator = class { return Mp4Generator.box('moov', this.mvhd_(firstStreamInfo), traks, - this.mvex_(firstStreamInfo), + this.mvex_(), this.pssh_(firstStreamInfo)); } @@ -130,9 +130,14 @@ shaka.util.Mp4Generator = class { */ tkhd_(streamInfo) { const Mp4Generator = shaka.util.Mp4Generator; + const ContentType = shaka.util.ManifestParserUtils.ContentType; const id = streamInfo.id + 1; - const width = streamInfo.stream.width || 0; - const height = streamInfo.stream.height || 0; + let width = streamInfo.stream.width || 0; + let height = streamInfo.stream.height || 0; + if (streamInfo.type == ContentType.AUDIO) { + width = 0; + height = 0; + } const duration = streamInfo.duration * streamInfo.timescale; const upperWordDuration = Math.floor(duration / (Mp4Generator.UINT32_MAX_ + 1)); @@ -689,13 +694,16 @@ shaka.util.Mp4Generator = class { /** * Generate a MVEX box * - * @param {shaka.util.Mp4Generator.StreamInfo} streamInfo * @return {!Uint8Array} * @private */ - mvex_(streamInfo) { + mvex_() { const Mp4Generator = shaka.util.Mp4Generator; - return Mp4Generator.box('mvex', this.trex_(streamInfo)); + let trexs = new Uint8Array([]); + for (const streamInfo of this.streamInfos_) { + trexs = shaka.util.Uint8ArrayUtils.concat(trexs, this.trex_(streamInfo)); + } + return Mp4Generator.box('mvex', trexs); } /**