Skip to content

Use native embedded subtitles for Matroska text tracks #457

Closed

Description

@tomislav

Problem

When Android or Android TV direct-plays an MKV with an embedded text subtitle selected, the app asks the server for a sidecar of that track instead of rendering it from the stream it is already playing. The server then reads the whole source file to extract the track. On large files on slow storage this takes minutes, competes with the video stream, and on sparse tracks (forced subtitles) the request goes silent and the app retries, each retry another full read. See Silo-Server/silo-server#1406.

MKV with SubRip or ASS is the most common embedded subtitle case, but native_embedded is currently advertised only for MP4 with mov_text (docs/playback/README.md, "Native embedded subtitles"), so every MKV text track goes through the sidecar path.

Proposal

Advertise native embedded subtitles for Matroska text tracks on original-HTTP delivery:

{"container": "mkv", "codecs": ["subrip", "ass"], "track_identity": "container_track_id"}

and select the track whose Media3 Format.id equals the plan's subtitle.embedded.container_track_id, as for MP4.

Media3 1.11.0 gives this identity: MatroskaExtractor sets each track's Format.id to its Matroska TrackNumber (initializeFormat(track.number) → Format.Builder.setId(int) → Integer.toString). This applies to SubRip, ASS/SSA, and WebVTT tracks.

Open points:

  • Whether ASS should go native or stay on the sidecar path, given styling and font attachments (ass_styling, font_attachments in the capability entry).
  • Behavior when the identity is missing or ambiguous should stay as today: report subtitle_embedded_failed and let the server replan to a sidecar.

Dependency

The server does not record container_track_id for Matroska yet (ffprobe does not expose TrackNumber), so the planner cannot choose the native route for MKV until it does. Tracked in Silo-Server/silo-server#1842. Until the server change ships, advertising the capability is harmless: the planner falls back to sidecars when the identity is missing.

Validation

  • Direct-play an MKV with an embedded SubRip track, including a sparse forced track: subtitles render from the stream, the plan carries subtitle.embedded, and the server logs no subtitle extraction for that playback.
  • Track switches between embedded MKV text tracks need no server request.
  • An MKV without recorded track IDs still falls back to the sidecar path.

Related issue: Silo-Server/silo-server#1842, Silo-Server/silo-server#1406

AI harness

Claude Code desktop app

AI tool(s)

Claude Code shell and file tools, GitHub CLI (read-only inspection of silo-android and Media3 1.11.0 source)

AI model(s)

claude-opus-5-5

AI involvement

AI-assisted

Independent or adversarial review

n/a

Activity

  1. tomislav commented on Oct 4, 2026

    @tomislav
    ContributorAuthor

    The server side is in review: Silo-Server/silo-server#1890. Notes for this issue:

    • Dependency: the "Dependency" section above now maps to #1890. With it, the scanner records each embedded MKV subtitle's TrackNumber as container_track_id, the same value Media3 puts in Format.id.
    • WebVTT: an MKV WebVTT track muxed as S_TEXT/WEBVTT gets no ID. FFmpeg does not recognize that codec, so the server cannot confirm which stream the track is, and those tracks stay on server extraction even if the app advertises webvtt. WebM's D_WEBVTT/SUBTITLES does get an ID.
    • Test files: include an MKV whose track numbers have gaps, for example a remux with tracks 1, 4, 5 and 6. Its subtitles are tracks 5 and 6 although they are streams 2 and 3, so an app that matches on stream index + 1 instead of container_track_id picks the wrong track. A production library of about 8,000 MKV files had 7 such files.
    • Rollout: files already in a library get their IDs from a startup backfill task after the server upgrade. Until it has run, those files have no ID and keep using server extraction, as the issue's fallback point expects.

    AI-assisted with Claude Code (claude-opus-5-5).

  2. added a commit that references this issue on Oct 6, 2026
    e21a0fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions