Skip to main content

Module mpv_tracks

Module mpv_tracks 

Source
Expand description

Subtitle and audio-track selection on mpv, by position, the way the frontend asks for it.

Until DR-235 mpv never drew video, so it never had to: subtitles were <track> children of the webview <video> and an audio track change re-opened the stream. With mpv the only desktop video renderer, it has to answer the same two calls ExoPlayer does, with the same meaning:

  • Subtitles are the sideloaded WebVTT list the play request carries (MediaItem::subtitles), and set_subtitle_track(n) selects the n-th of those — the position the frontend computes with nativeSubtitleArrayIndex. They reach mpv as external files queued on sub-files before the load, and selection starts off, because the menu opens on “Off”.
  • Audio set_audio_track(n) selects the n-th audio track of the file — the position in the item’s audio streams, which is file order. Only a direct play/stream carries every track; a transcode is re-opened instead (AudioTrackSwitchStrategy).

mpv’s own track ids are not positions: they count every track of a type, embedded before external, from 1. So a position is always resolved against the live track-list.

TRACES: UR-020, UR-021 | DR-023, DR-024, DR-235

Structs§

TrackInfo
One entry of mpv’s track-list, reduced to what selection needs.

Functions§

nth_track_id
The mpv id of the position-th track of kind (optionally only external or only embedded ones), in track-list order.
prepare_load
Prepare the next loadfile: these subtitle files will be loaded with it, no subtitle is shown, and the file’s default audio track plays.
select_audio
Play the position-th audio track of the file.
select_subtitle
Show the position-th sideloaded subtitle, or none.
track_list
Read the current track-list.