From 0367baa57a2ed09621f7f05b4d9f9a5780ce77d0 Mon Sep 17 00:00:00 2001 From: plantysnake Date: Wed, 26 Nov 2025 22:29:52 +0300 Subject: [PATCH 1/7] fix: Correct writing of 'stsz' box --- src/boxes/stsz.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/boxes/stsz.ts b/src/boxes/stsz.ts index 1573c9cf7..ba8b45dd1 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); From 56ab10a33f76abdab26e6bbe427dd2253d50f41c Mon Sep 17 00:00:00 2001 From: plantysnake Date: Wed, 26 Nov 2025 22:31:27 +0300 Subject: [PATCH 2/7] fix: Correct size calculation of 'mdat' box with unlimited size --- src/parser.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/parser.ts b/src/parser.ts index 7a560b643..e9c5a8cef 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; } } } From 6b7c9a3cdfa809be20e0956fc9888da68ef67b54 Mon Sep 17 00:00:00 2001 From: plantysnake Date: Wed, 26 Nov 2025 22:32:19 +0300 Subject: [PATCH 3/7] fix: Add check for null 'mehd' box --- src/isofile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isofile.ts b/src/isofile.ts index f02594ce7..3e93e0d6f 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -1306,7 +1306,7 @@ export class ISOFile { buffer: ISOFile.writeInitializationSegment( this.ftyp, moov, - this.moov?.mvex?.mehd.fragment_duration, + this.moov?.mvex?.mehd?.fragment_duration, ), }; } From 0f6f56edf37a198c38f45abe3f0f19b3051a22f5 Mon Sep 17 00:00:00 2001 From: plantysnake Date: Wed, 26 Nov 2025 22:33:08 +0300 Subject: [PATCH 4/7] fix: Update excluded conformance tests --- tests/conformance.test.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/conformance.test.ts b/tests/conformance.test.ts index 28ac5b49e..36c3f52fc 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 => { From 15209bf77f338a302fe4093d9c12d58351df43d5 Mon Sep 17 00:00:00 2001 From: plantysnake Date: Wed, 26 Nov 2025 22:37:51 +0300 Subject: [PATCH 5/7] fix: Make 'mehd' box optional in 'mvex' --- src/boxes/defaults.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boxes/defaults.ts b/src/boxes/defaults.ts index 1bdf5bc17..d50707e73 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 = []; From 528b3b94edc5d98a29961c7ee28c764351cd275e Mon Sep 17 00:00:00 2001 From: plantysnake Date: Sun, 14 Dec 2025 03:52:26 +0300 Subject: [PATCH 6/7] fix: Properly mark 'sbgp' box as optional in setSampleGroupProperties --- src/isofile.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/isofile.ts b/src/isofile.ts index 3e93e0d6f..1eb47bbdf 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -1443,14 +1443,14 @@ export class ISOFile { sample_groups_info[k].last_sample_in_run = 0; } sample_groups_info[k].entry_index++; - if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp.entries.length - 1) { + if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp?.entries.length - 1) { sample_groups_info[k].last_sample_in_run += - sample_groups_info[k].sbgp.entries[sample_groups_info[k].entry_index].sample_count; + sample_groups_info[k].sbgp?.entries[sample_groups_info[k].entry_index].sample_count; } } - if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp.entries.length - 1) { + if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp?.entries.length - 1) { sample.sample_groups[k].group_description_index = - sample_groups_info[k].sbgp.entries[ + sample_groups_info[k].sbgp?.entries[ sample_groups_info[k].entry_index ].group_description_index; } else { From 14c40ab2429e576d29cca839cd2cd5ef5b4cabf7 Mon Sep 17 00:00:00 2001 From: plantysnake Date: Sun, 14 Dec 2025 04:33:17 +0300 Subject: [PATCH 7/7] revert: Remove optional marking of 'sbgp' box --- src/isofile.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/isofile.ts b/src/isofile.ts index 1eb47bbdf..3e93e0d6f 100644 --- a/src/isofile.ts +++ b/src/isofile.ts @@ -1443,14 +1443,14 @@ export class ISOFile { sample_groups_info[k].last_sample_in_run = 0; } sample_groups_info[k].entry_index++; - if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp?.entries.length - 1) { + if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp.entries.length - 1) { sample_groups_info[k].last_sample_in_run += - sample_groups_info[k].sbgp?.entries[sample_groups_info[k].entry_index].sample_count; + sample_groups_info[k].sbgp.entries[sample_groups_info[k].entry_index].sample_count; } } - if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp?.entries.length - 1) { + if (sample_groups_info[k].entry_index <= sample_groups_info[k].sbgp.entries.length - 1) { sample.sample_groups[k].group_description_index = - sample_groups_info[k].sbgp?.entries[ + sample_groups_info[k].sbgp.entries[ sample_groups_info[k].entry_index ].group_description_index; } else {