{"record":{"id":"80626b5d48ca0dba","repo":"TeamNewPipe/NewPipe","slug":"missing-default-frame-time","errorCode":null,"errorMessage":"missing default frame time","messagePattern":"missing default frame time","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java","lineNumber":179,"sourceCode":"        final float resolution;\n        SimpleBlock bloq;\n        final ByteBuffer header = ByteBuffer.allocate(27 + (255 * 255));\n        final ByteBuffer page = ByteBuffer.allocate(64 * 1024);\n\n        header.order(ByteOrder.LITTLE_ENDIAN);\n\n        /* step 1: get the amount of frames per seconds */\n        switch (webmTrack.kind) {\n            case Audio:\n                resolution = getSampleFrequencyFromTrack(webmTrack.bMetadata);\n                if (resolution == 0f) {\n                    throw new RuntimeException(\"cannot get the audio sample rate\");\n                }\n                break;\n            case Video:\n                // WARNING: untested\n                if (webmTrack.defaultDuration == 0) {\n                    throw new RuntimeException(\"missing default frame time\");\n                }\n                resolution = 1000f / ((float) webmTrack.defaultDuration\n                        / webmSegment.info.timecodeScale);\n                break;\n            default:\n                throw new RuntimeException(\"not implemented\");\n        }\n\n        /* step 2: create packet with code init data */\n        if (webmTrack.codecPrivate != null) {\n            addPacketSegment(webmTrack.codecPrivate.length);\n            makePacketheader(0x00, header, webmTrack.codecPrivate);\n            write(header);\n            output.write(webmTrack.codecPrivate);\n        }\n\n        /* step 3: create packet with metadata */\n        final byte[] buffer = makeMetadata();","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/TeamNewPipe/NewPipe/blob/9e8be091560a69f35d44bd252eb00bc7911c977b/app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java#L161-L197","documentation":"OggFromWebMWriter computes frame resolution for a WebM Video track using webmTrack.defaultDuration. If defaultDuration is 0 the frame timing is unknown and Ogg granule math divides by it, so a RuntimeException is thrown. The writer explicitly marks video handling as untested (the code comment says so), meaning video-to-Ogg is experimental.","triggerScenarios":"Writing Ogg from a WebM Video track whose defaultDuration field is 0. Video-to-Ogg conversion is rarely used (Ogg is audio-centric) and the writer requires a non-zero defaultDuration to derive a frame rate.","commonSituations":"Passing a video track to OggFromWebMWriter (intended primarily for audio); a WebM whose track-level DefaultDuration element is absent; an encoder that omits per-track timing defaults.","solutions":["Pass an audio track to OggFromWebMWriter instead of a video track — Ogg output is designed for audio.","Use a WebM source whose video track declares a non-zero DefaultDuration (re-encode with ffmpeg -r to force it).","Select a different output container for video (e.g. WebM/Matroska) rather than Ogg.","Skip video conversion if the track lacks timing metadata."],"exampleFix":"// before — feeding a video track to an audio-oriented writer\nwriter.write(); // throws: defaultDuration == 0\n\n// after — select the audio track instead\nWebMTrack audio = Arrays.stream(reader.getAvailableTracks())\n    .filter(t -> t.kind == WebMTrack.Kind.Audio)\n    .findFirst().orElseThrow();\nreader.selectTrack(audio);","handlingStrategy":"validation","validationCode":"// Before writing, confirm a video track has non-zero defaultDuration.\nif (track.kind == WebMTrack.Kind.Video && track.defaultDuration == 0) {\n    throw new IOException(\"video track lacks DefaultDuration; cannot convert to Ogg\");\n}","typeGuard":"public static boolean videoTrackHasTiming(WebMTrack t) {\n    return t.kind == WebMTrack.Kind.Video && t.defaultDuration != 0;\n}","tryCatchPattern":"try {\n    writer.write();\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"default frame time\")) {\n        // video track has no timing — use an audio track instead\n        selectAudioTrack();\n    } else throw e;\n}","preventionTips":["Use OggFromWebMWriter for audio tracks, not video.","For video, choose a WebM/Matroska output container instead of Ogg.","Validate track.defaultDuration before writing video to Ogg.","Re-encode video sources with ffmpeg -r to force a DefaultDuration."],"tags":["ogg","webm","video","metadata","java"],"backgroundTag":null,"analyzedSha":"9e8be091560a69f35d44bd252eb00bc7911c977b","analyzedAt":"2026-08-14T00:11:33.519Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}