Skip to content

sub: add sub-lines property - #17730

Merged
kasper93 merged 3 commits into
mpv-player:masterfrom
guidocella:sub-lines
Apr 25, 2026
Merged

sub: add sub-lines property#17730
kasper93 merged 3 commits into
mpv-player:masterfrom
guidocella:sub-lines

Conversation

@guidocella

@guidocella guidocella commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

sub: add sub-lines property

Return all subtitle lines in memory with text, start and end.

I did not name this sub-all so it cannot be misinterpreted as referring to all subtitle tracks.

Closes #12810.

Mostly generated by Claude.

select.lua: use sub-lines instead of forking to ffmpeg

This:

  • Removes the dependency of ffmpeg in PATH - useful on Windows, macOS (?), Flatpak.
  • Will support subrandr.
  • Avoids redownloading network subtitles.
  • Avoids slow demuxing of large mkvs.
  • But no longer returns future lines of embedded subtitles.
  • No longer returns embedded lines of regions you seeked beyond without playing them (but holding the up key works) this depends if you enable the cache.
  • Changing sub track drops cached subtitles.

Comment thread player/lua/select.lua
Comment thread player/lua/select.lua Outdated
@afishhh

afishhh commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

The API used in the sd_sbr commit is something I conjured yesterday and is not released or in master yet, I'll open a separate PR for that once ready.

@guidocella

Copy link
Copy Markdown
Contributor Author

Removed.

@guidocella
guidocella force-pushed the sub-lines branch 2 times, most recently from bd8f1bb to 2089586 Compare April 18, 2026 16:13
Comment thread sub/dec_sub.c Outdated
Comment thread sub/sd_ass.c
Comment thread DOCS/man/input.rst Outdated
guidocella and others added 3 commits April 20, 2026 22:08
Return all subtitle lines in memory with text, start and end.

I did not name this sub-all so it cannot be misinterpreted as referring
to all subtitle tracks.

Closes mpv-player#12810.
This:

- Removes the dependency of ffmpeg in PATH - useful on Windows, macOS
  (?), Flatpak.
- Will support subrandr.
- Avoids redownloading network subtitles.
- Avoids slow demuxing of large mkvs.
- But no longer returns future lines of embedded subtitles.
- No longer returns embedded lines of regions you seeked beyond without
  playing them.
- Changing sub track drops cached subtitles.

@kasper93 kasper93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine with this if it works.

@kasper93
kasper93 merged commit 77ed8fe into mpv-player:master Apr 25, 2026
30 checks passed
@verygoodlee

Copy link
Copy Markdown
Contributor

Since secondary-sub-lines property is available, why not add a select-secondary-subtitle-line binding to select.lua, should be very easy.

Comment thread sub/dec_sub.c
}

static void dedup_sub_lines(struct sub_lines *lines)
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really necessary?

Even if the same text has overlapping time windows, they may be located at different positions. In such cases, they should not be counted as the same line.

ASS file content
[Script Info]
ScriptType: v4.00+
PlayResX: 1920
PlayResY: 1080
Aspect Ratio: 1920:1080
Collisions: Normal
WrapStyle: 2
ScaledBorderAndShadow: yes
YCbCr Matrix: TV.601

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Foo, sans-serif, 45, &H73FFFFFF, &H73FFFFFF, &H73000000, &H73000000, 0, 0, 0, 0, 100, 100, 0.00, 0.00, 1, 2, 0, 7, 0, 0, 0, 0

[Events]
Dialogue: 2,0:00:00.00,0:00:10.00,Foo,,0000,0000,0000,,{\move(1920, 0, -45, 0)}W
Dialogue: 2,0:00:05.00,0:00:15.00,Foo,,0000,0000,0000,,{\move(1920, 45, -45, 45)}W
Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah or you end up like #15936 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Displaying ASS without styles in a list is broken by design. You want to select subtitle, but at the same time you remove subtitles from the list.

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.

Add sub-text-all property

4 participants