TeamNewPipe/NewPipe · error · NoSuchElementException

Not a MPEG-4 DASH container, major brand is not 'dash' or 'i

Error message

Not a MPEG-4 DASH container, major brand is not 'dash' or 'iso5' is {}

What it means

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.

Source

Thrown at app/src/main/java/org/schabi/newpipe/streams/Mp4DashReader.java:85

    }

    public Mp4DashReader(final SharpStream source) {
        this.stream = new DataReader(source);
    }

    public void parse() throws IOException, NoSuchElementException {
        if (selectedTrack > -1) {
            return;
        }

        box = readBox(ATOM_FTYP);
        brands = parseFtyp(box);
        switch (brands[0]) {
            case BRAND_DASH:
            case BRAND_ISO5:// ¿why not?
                break;
            default:
                throw new NoSuchElementException(
                        "Not a MPEG-4 DASH container, major brand is not 'dash' or 'iso5' is "
                                + boxName(brands[0])
                );
        }

        Moov moov = null;
        int i;

        while (box.type != ATOM_MOOF) {
            ensure(box);
            box = readBox();

            switch (box.type) {
                case ATOM_MOOV:
                    moov = parseMoov(box);
                    break;
                case ATOM_SIDX:
                case ATOM_MFRA:

View on GitHub (pinned to 9e8be09156)

Solutions

  1. Select a DASH/fragmented source URL (itag with separate audio/video adaptive streams) instead of the muxed progressive itag.
  2. Pre-check the ftyp brand before parsing: read the first 8 bytes and confirm major brand is 'dash' (0x64617368) or 'iso5' (0x69736F35).
  3. If you only have a progressive MP4, use a different demuxer (e.g. a standard MP4 reader) — this class cannot process it.
  4. Re-mux with ffmpeg: ffmpeg -i in.mp4 -c copy -movflags +faststart+frag_keyframe+empty_moov out.mp4 to produce a fragmented file.

Example fix

// before
reader.parse(); // throws NoSuchElementException for progressive MP4

// after — sniff the ftyp major brand first
SharpStream s = ...;
byte[] head = new byte[8];
s.read(head);
int brand = ((head[4]&0xFF)<<24)|((head[5]&0xFF)<<16)|((head[6]&0xFF)<<8)|(head[7]&0xFF);
if (brand != 0x64617368 /*dash*/ && brand != 0x69736F35 /*iso5*/) {
    throw new IllegalArgumentException("not a fragmented DASH MP4");
}
Defensive patterns

Strategy: validation

Validate before calling

// Sniff the ftyp major brand before handing the stream to Mp4DashReader.
byte[] head = new byte[8];
if (source.read(head) != 8) throw new IOException("not enough bytes for ftyp");
int brand = ((head[4]&0xFF)<<24)|((head[5]&0xFF)<<16)|((head[6]&0xFF)<<8)|(head[7]&0xFF);
if (brand != 0x64617368 /*dash*/ && brand != 0x69736F35 /*iso5*/) {
    throw new IllegalArgumentException("not a fragmented DASH MP4 (brand=0x"+Integer.toHexString(brand)+")");
}

Type guard

public static boolean isFragmentedDashMp4(byte[] ftypHead) {
    if (ftypHead == null || ftypHead.length < 8) return false;
    int brand = ((ftypHead[4]&0xFF)<<24)|((ftypHead[5]&0xFF)<<16)|((ftypHead[6]&0xFF)<<8)|(ftypHead[7]&0xFF);
    return brand == 0x64617368 || brand == 0x69736F35;
}

Try / catch

try {
    reader.parse();
} catch (NoSuchElementException e) {
    if (e.getMessage().contains("major brand")) {
        // not a DASH file — switch to a DASH/adaptive source URL
        selectAdaptiveDashSource();
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of TeamNewPipe/NewPipe@9e8be09156 (2026-08-14). Data as JSON: /api/errors/fb7e060cebffe24b. Report an issue: GitHub.