{"record":{"id":"72f7d171669cdebc","repo":"TeamNewPipe/NewPipe","slug":"file-not-recognized-failed-to-demux-the-audio-str","errorCode":null,"errorMessage":"file not recognized, failed to demux the audio stream","messagePattern":"file not recognized, failed to demux the audio stream","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/us/shandian/giga/postprocessing/OggFromWebmDemuxer.java","lineNumber":32,"sourceCode":"        super(true, true, ALGORITHM_OGG_FROM_WEBM_DEMUXER);\n    }\n\n    @Override\n    boolean test(SharpStream... sources) throws IOException {\n        ByteBuffer buffer = ByteBuffer.allocate(4);\n        sources[0].read(buffer.array());\n\n        // youtube uses WebM as container, but the file extension (format suffix) is \"*.opus\"\n        // check if the file is a webm/mkv file before proceed\n\n        switch (buffer.getInt()) {\n            case 0x1a45dfa3:\n                return true;// webm/mkv\n            case 0x4F676753:\n                return false;// ogg\n        }\n\n        throw new UnsupportedOperationException(\"file not recognized, failed to demux the audio stream\");\n    }\n\n    @Override\n    int process(SharpStream out, @NonNull SharpStream... sources) throws IOException {\n        OggFromWebMWriter demuxer = new OggFromWebMWriter(sources[0], out, streamInfo);\n        demuxer.parseSource();\n        demuxer.selectTrack(0);\n        demuxer.build();\n\n        return OK_RESULT;\n    }\n}\n","sourceCodeStart":14,"sourceCodeEnd":45,"githubUrl":"https://github.com/TeamNewPipe/NewPipe/blob/9e8be091560a69f35d44bd252eb00bc7911c977b/app/src/main/java/us/shandian/giga/postprocessing/OggFromWebmDemuxer.java#L14-L45","documentation":"Thrown by OggFromWebmDemuxer.test() after reading the first 4 bytes of the source stream and switching on the big-endian integer. 0x1a45dfa3 is the EBML/WebM/Matroska magic header; 0x4F676753 is 'OggS' (the Ogg container magic). If neither matches, the file is neither a WebM/MKV nor an Ogg container, so the demuxer cannot proceed. This is a format-detection guard before the actual WebM-to-Ogg conversion.","triggerScenarios":"OggFromWebmDemuxer.test(sources) reads sources[0] first 4 bytes; buffer.getInt() matches neither 0x1a45dfa3 nor 0x4F676753; the switch falls through to the throw. Happens when the downloaded audio source is a different container (MP4/AAC, MP3, raw), is corrupt at offset 0, or the wrong postprocessor was selected for the stream's actual format.","commonSituations":"YouTube served an MP4/M4A audio stream but the postprocessor pipeline assumed WebM/Opus; the source file was replaced or corrupted; extractor version mismatch selecting the wrong stream format; a partial download where the first 4 bytes are garbage.","solutions":["Verify the source stream's actual container format before invoking this demuxer (check the MIME type or magic bytes upstream).","Ensure the extractor selected a WebM/Opus audio stream, not an MP4/M4A one — check the format selection logic.","If the source is already Ogg (.opus), skip this demuxer entirely (test() returns false for Ogg).","Re-download the source if the first bytes are corrupt (compare against expected format magic)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Read and check magic bytes before invoking the demuxer:\nByteBuffer magic = ByteBuffer.allocate(4);\nsource.read(magic.array());\nsource.seek(0); // rewind\nint sig = magic.getInt();\nif (sig != 0x1a45dfa3 && sig != 0x4F676753) {\n    throw new IOException(\"Source is neither WebM nor Ogg (magic=0x\" + Integer.toHexString(sig) + \")\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    demuxer.test(sources);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"file not recognized\")) {\n        // wrong format selected — skip this postprocessor or pick a different stream\n        Log.w(TAG, \"Source format not WebM/Ogg, skipping Ogg demux\", e);\n    } else throw e;\n}","preventionTips":["Match the postprocessor to the actual downloaded container format (check extractor's format info).","Pre-validate magic bytes before invoking format-specific demuxers.","If the source is already Ogg, skip the WebM-to-Ogg demuxer entirely."],"tags":["media","postprocessing","ogg","webm","format-detection"],"backgroundTag":null,"analyzedSha":"9e8be091560a69f35d44bd252eb00bc7911c977b","analyzedAt":"2026-08-14T00:11:33.519Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}