From 49994bf9ed358f3ef0c540249982b8a7875642e5 Mon Sep 17 00:00:00 2001 From: Vanilagy <1696106+Vanilagy@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:22:21 +0100 Subject: [PATCH] Remove hackiness in "moof"-starting mp4 segments --- src/input-format.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/input-format.ts b/src/input-format.ts index cb137e8..804a87b 100644 --- a/src/input-format.ts +++ b/src/input-format.ts @@ -69,7 +69,6 @@ export abstract class IsobmffInputFormat extends InputFormat { if ( fourCc !== 'ftyp' && fourCc !== 'styp' // Segment - && fourCc !== 'moof' // Not a legal segment, but seen in practice (sigh) ) { return null; } @@ -95,7 +94,15 @@ export class Mp4InputFormat extends IsobmffInputFormat { /** @internal */ async _canReadInput(input: Input) { const majorBrand = await this._getMajorBrand(input); - return !!majorBrand && majorBrand !== 'qt '; + if (majorBrand !== null) { + return majorBrand !== 'qt '; + } + + let slice = input._reader.requestSlice(4, 4); + if (slice instanceof Promise) slice = await slice; + if (!slice) return false; + + return readAscii(slice, 4) === 'moof'; // Not a legal segment start, but seen in practice (sigh) } get name() {