diff --git a/src/boxes/defaults.ts b/src/boxes/defaults.ts index 1bdf5bc1..d50707e7 100644 --- a/src/boxes/defaults.ts +++ b/src/boxes/defaults.ts @@ -233,7 +233,7 @@ export class mvexBox extends ContainerBox { static override readonly fourcc = 'mvex' as const; box_name = 'MovieExtendsBox' as const; trex: trexBox; - mehd: mehdBox; + mehd?: mehdBox; mehds: Array; trexs: Array = []; diff --git a/src/boxes/stsz.ts b/src/boxes/stsz.ts index 1573c9cf..ba8b45dd 100644 --- a/src/boxes/stsz.ts +++ b/src/boxes/stsz.ts @@ -30,17 +30,7 @@ export class stszBox extends FullBox { let constant = true; this.version = 0; this.flags = 0; - if (this.sample_sizes.length > 0) { - let i = 0; - while (i + 1 < this.sample_sizes.length) { - if (this.sample_sizes[i + 1] !== this.sample_sizes[0]) { - constant = false; - break; - } else { - i++; - } - } - } else { + if (this.sample_sizes.length > 0 && this.sample_size === 0) { constant = false; } this.size = 8; @@ -48,11 +38,7 @@ export class stszBox extends FullBox { this.size += 4 * this.sample_sizes.length; } this.writeHeader(stream); - if (!constant) { - stream.writeUint32(0); - } else { - stream.writeUint32(this.sample_sizes[0]); - } + stream.writeUint32(this.sample_size); stream.writeUint32(this.sample_sizes.length); if (!constant) { stream.writeUint32Array(this.sample_sizes); diff --git a/src/isofile.ts b/src/isofile.ts index d2d8c334..f0a5f41e 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -1337,7 +1337,7 @@ export class ISOFile { buffer: ISOFile.writeInitializationSegment( this.ftyp, moov, - this.moov?.mvex?.mehd.fragment_duration, + this.moov?.mvex?.mehd?.fragment_duration, ), }; } diff --git a/src/parser.ts b/src/parser.ts index 7a560b64..e9c5a8ce 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -87,6 +87,8 @@ export function parseOneBox( box = new Box(size); box.type = type as BoxFourCC; return { code: OK, box, size: box.size }; + } else { + size = stream.getEndPosition() - start; } } } diff --git a/tests/conformance.test.ts b/tests/conformance.test.ts index 28ac5b49..36c3f52f 100644 --- a/tests/conformance.test.ts +++ b/tests/conformance.test.ts @@ -253,16 +253,7 @@ describe('Conformance Tests', () => { file_groups[groupName].filter(test => { // FIXME: These files might be correct but I haven't investigated them yet // Majority of the tests pass so I've left them out for now - const ignoredTests = [ - 'video_2500000bps_0.mp4', - 'a3b-tone-deprot.mp4', - 'a4-tone-fragmented.mp4', - 'a6_tone_multifile.mp4', - 'a7-tone-oddities.mp4', - 'a9-aac-samplegroups-edit.mp4', - 'hevc/hevc_tiles_multiple_tracks_empty_base.mp4', - 'hevc/hevc_tiles_multiple_tracks.mp4', - ]; + const ignoredTests = ['video_2500000bps_0.mp4']; return !ignoredTests.includes(test); }), )('roundtrip %s', async testName => {