TeamNewPipe/NewPipe · error · RuntimeException

missing default frame time

Error message

missing default frame time

What it means

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.

Source

Thrown at app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java:179

        final float resolution;
        SimpleBlock bloq;
        final ByteBuffer header = ByteBuffer.allocate(27 + (255 * 255));
        final ByteBuffer page = ByteBuffer.allocate(64 * 1024);

        header.order(ByteOrder.LITTLE_ENDIAN);

        /* step 1: get the amount of frames per seconds */
        switch (webmTrack.kind) {
            case Audio:
                resolution = getSampleFrequencyFromTrack(webmTrack.bMetadata);
                if (resolution == 0f) {
                    throw new RuntimeException("cannot get the audio sample rate");
                }
                break;
            case Video:
                // WARNING: untested
                if (webmTrack.defaultDuration == 0) {
                    throw new RuntimeException("missing default frame time");
                }
                resolution = 1000f / ((float) webmTrack.defaultDuration
                        / webmSegment.info.timecodeScale);
                break;
            default:
                throw new RuntimeException("not implemented");
        }

        /* step 2: create packet with code init data */
        if (webmTrack.codecPrivate != null) {
            addPacketSegment(webmTrack.codecPrivate.length);
            makePacketheader(0x00, header, webmTrack.codecPrivate);
            write(header);
            output.write(webmTrack.codecPrivate);
        }

        /* step 3: create packet with metadata */
        final byte[] buffer = makeMetadata();

View on GitHub (pinned to 9e8be09156)

Solutions

  1. Pass an audio track to OggFromWebMWriter instead of a video track — Ogg output is designed for audio.
  2. Use a WebM source whose video track declares a non-zero DefaultDuration (re-encode with ffmpeg -r to force it).
  3. Select a different output container for video (e.g. WebM/Matroska) rather than Ogg.
  4. Skip video conversion if the track lacks timing metadata.

Example fix

// before — feeding a video track to an audio-oriented writer
writer.write(); // throws: defaultDuration == 0

// after — select the audio track instead
WebMTrack audio = Arrays.stream(reader.getAvailableTracks())
    .filter(t -> t.kind == WebMTrack.Kind.Audio)
    .findFirst().orElseThrow();
reader.selectTrack(audio);
Defensive patterns

Strategy: validation

Validate before calling

// Before writing, confirm a video track has non-zero defaultDuration.
if (track.kind == WebMTrack.Kind.Video && track.defaultDuration == 0) {
    throw new IOException("video track lacks DefaultDuration; cannot convert to Ogg");
}

Type guard

public static boolean videoTrackHasTiming(WebMTrack t) {
    return t.kind == WebMTrack.Kind.Video && t.defaultDuration != 0;
}

Try / catch

try {
    writer.write();
} catch (RuntimeException e) {
    if (e.getMessage().contains("default frame time")) {
        // video track has no timing — use an audio track instead
        selectAudioTrack();
    } else throw e;
}

Prevention

When it happens

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

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

Related errors


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