{"record":{"id":"fb7e060cebffe24b","repo":"TeamNewPipe/NewPipe","slug":"not-a-mpeg-4-dash-container-major-brand-is-not-d","errorCode":null,"errorMessage":"Not a MPEG-4 DASH container, major brand is not 'dash' or 'iso5' is {}","messagePattern":"Not a MPEG-4 DASH container, major brand is not 'dash' or 'iso5' is (.+?)","errorType":"exception","errorClass":"NoSuchElementException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/schabi/newpipe/streams/Mp4DashReader.java","lineNumber":85,"sourceCode":"    }\n\n    public Mp4DashReader(final SharpStream source) {\n        this.stream = new DataReader(source);\n    }\n\n    public void parse() throws IOException, NoSuchElementException {\n        if (selectedTrack > -1) {\n            return;\n        }\n\n        box = readBox(ATOM_FTYP);\n        brands = parseFtyp(box);\n        switch (brands[0]) {\n            case BRAND_DASH:\n            case BRAND_ISO5:// ¿why not?\n                break;\n            default:\n                throw new NoSuchElementException(\n                        \"Not a MPEG-4 DASH container, major brand is not 'dash' or 'iso5' is \"\n                                + boxName(brands[0])\n                );\n        }\n\n        Moov moov = null;\n        int i;\n\n        while (box.type != ATOM_MOOF) {\n            ensure(box);\n            box = readBox();\n\n            switch (box.type) {\n                case ATOM_MOOV:\n                    moov = parseMoov(box);\n                    break;\n                case ATOM_SIDX:\n                case ATOM_MFRA:","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/TeamNewPipe/NewPipe/blob/9e8be091560a69f35d44bd252eb00bc7911c977b/app/src/main/java/org/schabi/newpipe/streams/Mp4DashReader.java#L67-L103","documentation":"Mp4DashReader.parse() reads the ftyp (file-type) box and checks the first (major) brand. Only BRAND_DASH ('dash') and BRAND_ISO5 ('iso5') are accepted as fragmented-MP4 containers; any other major brand throws NoSuchElementException naming the offending brand. This is a hard format gate: the reader is a fragmented-DASH demuxer and will not process a 'qt  ', 'isom', or 'M4V ' progressive MP4.","triggerScenarios":"Calling Mp4DashReader.parse() on a progressive (non-fragmented) MP4/M4A whose ftyp major brand is 'isom', 'qt  ', 'M4A ', 'M4V ', 'mp42', etc. Also triggered by a file that is actually a QuickTime MOV or an un-fragmented download the muxer emitted before fragmentation.","commonSituations":"Feeding a YouTube 'progressive' (muxed) URL into the DASH demuxer; an M4A iTunes download; a re-muxed file produced by ffmpeg without the -movflags +faststart+frag_keyframe+empty_moov flags; a stream whose extractor returned the itag for a non-DASH variant.","solutions":["Select a DASH/fragmented source URL (itag with separate audio/video adaptive streams) instead of the muxed progressive itag.","Pre-check the ftyp brand before parsing: read the first 8 bytes and confirm major brand is 'dash' (0x64617368) or 'iso5' (0x69736F35).","If you only have a progressive MP4, use a different demuxer (e.g. a standard MP4 reader) — this class cannot process it.","Re-mux with ffmpeg: ffmpeg -i in.mp4 -c copy -movflags +faststart+frag_keyframe+empty_moov out.mp4 to produce a fragmented file."],"exampleFix":"// before\nreader.parse(); // throws NoSuchElementException for progressive MP4\n\n// after — sniff the ftyp major brand first\nSharpStream s = ...;\nbyte[] head = new byte[8];\ns.read(head);\nint brand = ((head[4]&0xFF)<<24)|((head[5]&0xFF)<<16)|((head[6]&0xFF)<<8)|(head[7]&0xFF);\nif (brand != 0x64617368 /*dash*/ && brand != 0x69736F35 /*iso5*/) {\n    throw new IllegalArgumentException(\"not a fragmented DASH MP4\");\n}","handlingStrategy":"validation","validationCode":"// Sniff the ftyp major brand before handing the stream to Mp4DashReader.\nbyte[] head = new byte[8];\nif (source.read(head) != 8) throw new IOException(\"not enough bytes for ftyp\");\nint brand = ((head[4]&0xFF)<<24)|((head[5]&0xFF)<<16)|((head[6]&0xFF)<<8)|(head[7]&0xFF);\nif (brand != 0x64617368 /*dash*/ && brand != 0x69736F35 /*iso5*/) {\n    throw new IllegalArgumentException(\"not a fragmented DASH MP4 (brand=0x\"+Integer.toHexString(brand)+\")\");\n}","typeGuard":"public static boolean isFragmentedDashMp4(byte[] ftypHead) {\n    if (ftypHead == null || ftypHead.length < 8) return false;\n    int brand = ((ftypHead[4]&0xFF)<<24)|((ftypHead[5]&0xFF)<<16)|((ftypHead[6]&0xFF)<<8)|(ftypHead[7]&0xFF);\n    return brand == 0x64617368 || brand == 0x69736F35;\n}","tryCatchPattern":"try {\n    reader.parse();\n} catch (NoSuchElementException e) {\n    if (e.getMessage().contains(\"major brand\")) {\n        // not a DASH file — switch to a DASH/adaptive source URL\n        selectAdaptiveDashSource();\n    } else throw e;\n}","preventionTips":["Always request the DASH/adaptive itag from the extractor, not the progressive muxed one.","Sniff the ftyp brand from the first 8 bytes before committing to Mp4DashReader.","Keep progressive MP4s away from the DASH reader — use a different demuxer for them.","Test with known-good fragmented MP4 samples during development."],"tags":["mp4","dash","format-validation","container","java"],"backgroundTag":null,"analyzedSha":"9e8be091560a69f35d44bd252eb00bc7911c977b","analyzedAt":"2026-08-14T00:11:33.519Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}