Skip to content

sub/sd_sbr: pass track language to sbr_load_text#17273

Merged
kasper93 merged 1 commit intompv-player:masterfrom
afishhh:sbr-pass-lang
Jan 15, 2026
Merged

sub/sd_sbr: pass track language to sbr_load_text#17273
kasper93 merged 1 commit intompv-player:masterfrom
afishhh:sbr-pass-lang

Conversation

@afishhh
Copy link
Contributor

@afishhh afishhh commented Jan 15, 2026

The language hint is required for correct handling of RTL in srv3 so
provide the best-effort guess from the subtitle track.

Without this hint some RTL paragraphs are going to be wrongly assumed
LTR and reorder incorrectly. Additionally, subrandr may soon start
treating srv3 segments as inline-blocks which means guessing is not
going to be possible anymore (at least as part of unicode bidi algorithm).


This will alleviate the issue from #12978 when using srv3 subtitles (careful wording to not close that issue in case we still want to track it for other formats). I tested it with the example subtitle line provided in that issue (manually transplanted to srv3) and it seemed to work.

Currently does nothing. With afishhh/subrandr#139 it gets parsed as a LanguageIdentifier (Unicode BCP47), canonicalized, and its directionality used for base paragraph direction (direction CSS property on root inline box of srv3 lines).

Also: sometimes yt-dlp attaches weird stuff like en-sAO4vbAqVZo or en-sAO4vbAqVZo which will fail to even be detected as a language tag by mpv, not sure what to do about that (even if it did it would fail in subrandr, could probably special case in both but let's not complicate for now?).

The language hint is required for *correct* handling of RTL in srv3 so
provide the best-effort guess from the subtitle track.

Without this hint some RTL paragraphs are going to be wrongly assumed
LTR and reorder incorrectly. Additionally, subrandr may soon start
treating srv3 segments as `inline-block`s which means guessing is not
going to be possible anymore (at least as part of unicode bidi algorithm).
Copy link
Member

@kasper93 kasper93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kasper93 kasper93 merged commit fa44f67 into mpv-player:master Jan 15, 2026
30 checks passed
@afishhh afishhh deleted the sbr-pass-lang branch January 19, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants