TeamNewPipe/NewPipe · error · NoSuchElementException

Element Timecode not found

Error message

Element Timecode not found

What it means

WebMReader parses the Segment Info element and expects a TimecodeScale child (which converts segment timecodes to nanoseconds). After scanning Info, if info.timecodeScale is still 0 it throws NoSuchElementException 'Element Timecode not found'. Without a timecode scale, duration math is impossible, so the segment is rejected.

Source

Thrown at app/src/main/java/org/schabi/newpipe/streams/WebMReader.java:267

    private Info readInfo(final Element ref) throws IOException {
        Element elem;
        final Info info = new Info();

        while ((elem = untilElement(ref, ID_TIMECODE_SCALE, ID_DURATION)) != null) {
            switch (elem.type) {
                case ID_TIMECODE_SCALE:
                    info.timecodeScale = readNumber(elem);
                    break;
                case ID_DURATION:
                    info.duration = readNumber(elem);
                    break;
            }
            ensure(elem);
        }

        if (info.timecodeScale == 0) {
            throw new NoSuchElementException("Element Timecode not found");
        }

        return info;
    }

    private Segment readSegment(final Element ref, final int trackLacingExpected,
                                final boolean metadataExpected) throws IOException {
        final Segment obj = new Segment(ref);
        Element elem;
        while ((elem = untilElement(ref, ID_INFO, ID_TRACKS, ID_CLUSTER)) != null) {
            if (elem.type == ID_CLUSTER) {
                obj.currentCluster = elem;
                break;
            }
            switch (elem.type) {
                case ID_INFO:
                    obj.info = readInfo(elem);
                    break;

View on GitHub (pinned to 9e8be09156)

Solutions

  1. Use a well-formed WebM source — TimecodeScale is mandatory in the spec and any conformant file has it.
  2. Re-mux with ffmpeg/ffmpeg -f webm to regenerate the Info element with TimecodeScale.
  3. Pre-scan the Info element for TimecodeScale before fully parsing.
  4. Validate the file with mkvinfo to confirm Info/TimecodeScale is present.

Example fix

// before
new WebMReader(malformedWebM).parse(); // throws: TimecodeScale missing

// after — remux to guarantee required metadata
ffmpeg -i in.webm -c copy -f webm out.webm
new WebMReader(outWebM).parse();
Defensive patterns

Strategy: validation

Validate before calling

// Pre-scan the Segment Info element for a TimecodeScale child before full parse.
// Easiest: validate with mkvinfo that Info/TimecodeScale is present,
// or remux with ffmpeg -f webm to guarantee required metadata.

Type guard

public static boolean hasTimecodeScale(SegmentInfo info) {
    return info != null && info.timecodeScale != 0;
}

Try / catch

try {
    reader.parse();
} catch (NoSuchElementException e) {
    if (e.getMessage().contains("Timecode not found")) {
        // Info lacks TimecodeScale — re-mux to repair metadata
        remuxWithFfmpegWebM();
    } else throw e;
}

Prevention

When it happens

Trigger: Parsing a WebM whose Segment Info element lacks the TimecodeScale child, or where the Info element is absent/empty. The reader requires TimecodeScale to interpret all cluster/block timestamps.

Common situations: A malformed WebM missing the TimecodeScale element; a file produced by a non-conformant muxer that omits it; a truncated Info element; a manually constructed Matroska missing required metadata.

Related errors


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