summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-04 01:43:14 +0200
committerwm4 <wm4@nowhere>2013-04-04 14:45:29 +0200
commit75afa370b9aba90be73b8acc97eb9669bc0f2133 (patch)
treeddbf1ef6a0c9008e19bd48a20511327db6f0acb2 /core
parentf36a5a88d0ac17e8fdc1885d2f3bf95e903d54e3 (diff)
downloadmpv-75afa370b9aba90be73b8acc97eb9669bc0f2133.tar.bz2
mpv-75afa370b9aba90be73b8acc97eb9669bc0f2133.tar.xz
demux_mkv: try to show current subtitle when seeking
Makes sure that seeking to a given time position shows the subtitle at that position. This can fail if the subtitle packet is not close enough to the seek target. Always enabled for hr-seeks, and can be manually enabled for normal seeks with --mkv-subtitle-preroll. This helps displaying subtitles correctly with ordered chapters. When switching ordered chapter segments, a seek is performed. If the subtitle is timed slightly before the start of the segment, it normally won't be demuxed. This is a problem with all seeks, but in this case normal playback is affected. Since switching segments always uses hr-seeks, the code added by this commit is always active in this situation. If no subtitles are selected or the subtitles come from an external file, the demuxer should behave exactly as before this commit.
Diffstat (limited to 'core')
-rw-r--r--core/cfg-mplayer.h1
-rw-r--r--core/mplayer.c2
-rw-r--r--core/options.h1
3 files changed, 4 insertions, 0 deletions
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 4bdead1be1..a85f83ac36 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -391,6 +391,7 @@ const m_option_t common_opts[] = {
OPT_STRING("audio-demuxer", audio_demuxer_name, 0),
OPT_STRING("sub-demuxer", sub_demuxer_name, 0),
OPT_FLAG("extbased", extension_parsing, 0),
+ OPT_FLAG("mkv-subtitle-preroll", mkv_subtitle_preroll, 0),
{"mf", (void *) mfopts_conf, CONF_TYPE_SUBCONFIG, 0,0,0, NULL},
#ifdef CONFIG_RADIO
diff --git a/core/mplayer.c b/core/mplayer.c
index 21af9ca57a..3833d0a7da 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -2821,6 +2821,8 @@ static int seek(MPContext *mpctx, struct seek_params seek,
demuxer_style |= SEEK_BACKWARD;
else if (seek.direction > 0)
demuxer_style |= SEEK_FORWARD;
+ if (hr_seek || opts->mkv_subtitle_preroll)
+ demuxer_style |= SEEK_SUBPREROLL;
if (hr_seek)
demuxer_amount -= opts->hr_seek_demuxer_offset;
diff --git a/core/options.h b/core/options.h
index 0f1df17ba5..716ad5c357 100644
--- a/core/options.h
+++ b/core/options.h
@@ -140,6 +140,7 @@ typedef struct MPOpts {
char *audio_demuxer_name;
char *sub_demuxer_name;
int extension_parsing;
+ int mkv_subtitle_preroll;
struct image_writer_opts *screenshot_image_opts;
char *screenshot_template;