1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00

sd_ass: introduce sub-ass-prune-delay

Disabled by default because it breaks sub-seek and playback in cases
where the user changes play-dir from + to - during runtime and past
"seen" events need to be re-rendered.

Available since dcc9eb722e
This commit is contained in:
llyyr 2024-10-30 17:44:42 +05:30 committed by Kacper Michajłow
parent 9bf0c53763
commit 22116734e7
5 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,2 @@
add `sub-ass-prune-delay` option to control libass automatic pruning of past
events

View File

@ -2533,6 +2533,22 @@ Subtitles
``complex`` is the default. If libass hasn't been compiled against HarfBuzz,
libass silently reverts to ``simple``.
``--sub-ass-prune-delay=<-1|seconds>``
Set the delay for automatic pruning of events from memory in libass. When
enabled, subtitle events are removed from memory once their end timestamp is
older than the specified delay.
:-1: disables automatic pruning (default).
:seconds: specify how many seconds after an event is no longer displayed
should the pruning occur. ``0`` prunes events as soon as they're
off screen.
.. note::
This breaks sub-seek and subtitle rendering when changing play-direction
from forward to backward during runtime for events that were already
"seen" and need to be rendered again, if those events got pruned.
``--sub-ass-styles=<filename>``
Load all SSA/ASS styles found in the specified file and use them for
rendering text subtitles. The syntax of the file is exactly like the ``[V4

View File

@ -336,6 +336,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"none", 0}, {"light", 1}, {"normal", 2}, {"native", 3})},
{"sub-ass-shaper", OPT_CHOICE(ass_shaper,
{"simple", 0}, {"complex", 1})},
{"sub-ass-prune-delay", OPT_DOUBLE(ass_prune_delay), M_RANGE(-1.0, DBL_MAX)},
{"sub-ass-justify", OPT_BOOL(ass_justify)},
{"sub-scale-by-window", OPT_BOOL(sub_scale_by_window)},
{"sub-scale-with-window", OPT_BOOL(sub_scale_with_window)},
@ -355,6 +356,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
.sub_scale_by_window = true,
.sub_use_margins = true,
.sub_scale_with_window = true,
.ass_prune_delay = -1.0,
.teletext_page = 0,
.sub_scale = 1,
.ass_vsfilter_color_compat = 1,

View File

@ -118,6 +118,7 @@ struct mp_subtitle_opts {
char *ass_styles_file;
int ass_hinting;
int ass_shaper;
double ass_prune_delay;
bool ass_justify;
bool sub_clear_on_seek;
int teletext_page;

View File

@ -247,6 +247,10 @@ static void assobjects_init(struct sd *sd)
ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
#endif
#if LIBASS_VERSION >= 0x01703010
ass_configure_prune(ctx->ass_track, sd->opts->ass_prune_delay * 1000.0);
#endif
enable_output(sd, true);
}