{"record":{"id":"ea9ac62364ca388b","repo":"remotion-dev/remotion","slug":"expected-an-mp4-file","errorCode":null,"errorMessage":"Expected an mp4 file","messagePattern":"Expected an mp4 file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/m3u/process-m3u-chunk.ts","lineNumber":341,"sourceCode":"\t\t\t\t\t\t\t\t\t\t\tcallback: callbackOrFalse,\n\t\t\t\t\t\t\t\t\t\t\tparentController: state.controller,\n\t\t\t\t\t\t\t\t\t\t\tchildController,\n\t\t\t\t\t\t\t\t\t\t\tsubtractChunks: chunksToSubtract,\n\t\t\t\t\t\t\t\t\t\t\tchunkIndex,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\treader: state.readerInterface,\n\t\t\t\t\tmakeSamplesStartAtZero: false,\n\t\t\t\t\tm3uPlaylistContext: {\n\t\t\t\t\t\tmp4HeaderSegment,\n\t\t\t\t\t\tisLastChunkInPlaylist: isLastChunk,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (chunk.isHeader) {\n\t\t\t\t\tif (data.slowStructure.type !== 'iso-base-media') {\n\t\t\t\t\t\tthrow new Error('Expected an mp4 file');\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.m3u.setMp4HeaderSegment(playlistUrl, data.slowStructure);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcurrentPromise.rejector(e as Error);\n\t\t\t\tthrow e;\n\t\t\t}\n\n\t\t\tforwarded.cleanup();\n\n\t\t\tif (!isLastChunk) {\n\t\t\t\tchildController.pause();\n\t\t\t\tcurrentPromise.resolver(makeContinuationFn());\n\t\t\t}\n\t\t}\n\n\t\tcurrentPromise.resolver(null);","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/m3u/process-m3u-chunk.ts#L323-L359","documentation":"Thrown during HLS chunk processing when a segment marked as an initialization header (`chunk.isHeader === true`) is parsed and its underlying container structure type is not `iso-base-media` (MP4/fragmented MP4). The parser expects HLS init segments to be MP4 `ftyp`/`moov` boxes; encountering a different container means the stream format is incompatible.","triggerScenarios":"An HLS playlist whose `#EXT-X-MAP` (init segment) references a non-MP4 file — e.g., a WebM, MPEG-TS, or raw AAC initialization segment — and the chunk's `data.slowStructure.type` resolves to something other than `'iso-base-media'`.","commonSituations":"HLS streams that use MPEG-TS or fMP4 with non-standard encapsulation. Manifests where the init segment URL points to the wrong file. Misconfigured CDN serving a segment body for what should be an init segment. Non-MP4 HLS variants the media-parser doesn't support.","solutions":["Verify the HLS init segment (`#EXT-X-MAP:URI=...`) is a valid fragmented MP4 file.","If the stream is MPEG-TS-based HLS, check whether `@remotion/media-parser` supports that variant; it currently expects fMP4 init segments.","Switch to an MP4/fMP4-based HLS encoding if you control the content.","Report the stream at remotion.dev/report if it is a standard fMP4 HLS stream that should work."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src: 'https://example.com/stream.m3u8'});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Expected an mp4 file') {\n    console.error(\n      'The HLS init segment is not an MP4/fMP4 file. ' +\n      'Ensure the stream uses fragmented MP4 segments.'\n    );\n  }\n  throw e;\n}","preventionTips":["Ensure HLS streams use fragmented MP4 (fMP4) init segments, not MPEG-TS or WebM.","Verify #EXT-X-MAP URI points to a valid fMP4 init segment.","Test HLS streams with standard players before parsing with @remotion/media-parser."],"tags":["hls","m3u8","mp4","init-segment","container-mismatch"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}