Skip to content

Commit

Permalink
fix: Fix Mp4Generator (#5566)
Browse files Browse the repository at this point in the history
Fixes the mvex generation
Removes width and height from tkhd box for audio tracks
  • Loading branch information
avelad authored and joeyparrish committed Sep 2, 2023
1 parent 1c32895 commit a20f1db
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/util/mp4_generator.js
Expand Up @@ -55,7 +55,7 @@ shaka.util.Mp4Generator = class {
return Mp4Generator.box('moov',
this.mvhd_(firstStreamInfo),
traks,
this.mvex_(firstStreamInfo),
this.mvex_(),
this.pssh_(firstStreamInfo));
}

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit a20f1db

Please sign in to comment.