diff options
authorrcombs <>2020-12-23 00:40:32 -0600
committerrcombs <>2020-12-23 00:40:32 -0600
commitcc2a0f2307a1683fe6b1d08ffb2e3521870a7498 (patch)
parent40ea28c6f9f2f62270c1d07e4d79109d0a2d6b7d (diff)
sub: by default, don't render timestamps after video EOFlast-frame-subs
This fixes a long-standing apparent issue where mpv would display the last frame with no subtitles at EOF. This is caused by sub rendering switching from video timestamps to audio timestamps when the video ends, and audio streams often running past the timestamp of the last video frame. However, authoring tools (most notably Aegisub) don't tend to provide easy ways to add meaningful subtitles after the end of the video, so this is rarely actually useful.
4 files changed, 9 insertions, 1 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index c92353a2a6..01ea53bef4 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2587,6 +2587,11 @@ Subtitles
This works for ``dvb_teletext`` subtitle streams, and if FFmpeg has been
compiled with support for it.
+ After the last frame of video, if this option is enabled, subtitles will
+ continue to update based on audio timestamps. Otherwise, the subtitles
+ for the last video frame will stay onscreen.
Specify font to use for subtitles that do not themselves
specify a particular font. The default is ``sans-serif``.
diff --git a/options/options.c b/options/options.c
index 8aadc87ab9..f9cdeb9ba2 100644
--- a/options/options.c
+++ b/options/options.c
@@ -271,6 +271,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"sub", OPT_SUBSTRUCT(sub_style, sub_style_conf)},
{"sub-clear-on-seek", OPT_FLAG(sub_clear_on_seek)},
{"teletext-page", OPT_INT(teletext_page), M_RANGE(1, 999)},
+ {"sub-past-video-end", OPT_FLAG(sub_past_video_end)},
.size = sizeof(OPT_BASE_STRUCT),
diff --git a/options/options.h b/options/options.h
index f28c054500..24bd213b31 100644
--- a/options/options.h
+++ b/options/options.h
@@ -106,6 +106,7 @@ struct mp_subtitle_opts {
int ass_justify;
int sub_clear_on_seek;
int teletext_page;
+ int sub_past_video_end;
struct mp_sub_filter_opts {
diff --git a/player/sub.c b/player/sub.c
index ae2a85ac1c..49bae790de 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -114,7 +114,8 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts,
// Handle displaying subtitles on VO with no video being played. This is
// quite different, because normally subtitles are redrawn on new video
// frames, using the video frames' timestamps.
- if (mpctx->video_out && mpctx->video_status == STATUS_EOF) {
+ if (mpctx->video_out && mpctx->video_status == STATUS_EOF &&
+ mpctx->opts->subs_rend->sub_past_video_end) {
if (osd_get_force_video_pts(mpctx->osd) != video_pts) {
osd_set_force_video_pts(mpctx->osd, video_pts);