summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-10-07 17:16:03 +0200
committerwm4 <wm4@nowhere>2013-10-07 17:21:53 +0200
commitde6eace6e984be3cd2515e9be6362a0cf04b7457 (patch)
tree04b8671b07e9d08aacbc5743623eac7474e2c83b /mpvcore
parentccdaecfc5cc53b6c6ca3f46ca37ff74a36eb58dd (diff)
downloadmpv-de6eace6e984be3cd2515e9be6362a0cf04b7457.tar.bz2
mpv-de6eace6e984be3cd2515e9be6362a0cf04b7457.tar.xz
command: sub_seek: avoid getting stuck
First, don't try to seek if the result is 0 (i.e. nothing found, or subtitle event happens to be exactly on spot). Second, since we never can make sure that we actually seek to the exact subtitle PTS (seeking "snaps" to video PTS), offset the seek by 10ms. Since most subtitle events are longer than 10ms, this should work fine.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/command.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index 038e58bc8d..f16d171bf4 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -2502,6 +2502,11 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration,
"Sub delay: %d ms", ROUND(opts->sub_delay * 1000));
} else {
+ // We can easily get stuck by failing to seek to the video
+ // frame which actually shows the sub first (because video
+ // frame PTS and sub PTS rarely match exactly). Add some
+ // rounding for the mess of it.
+ a[0] += 0.01 * (a[1] > 0 ? 1 : -1);
queue_seek(mpctx, MPSEEK_RELATIVE, a[0], 1);
set_osd_function(mpctx, (a[0] > 0) ? OSD_FFW : OSD_REW);
if (bar_osd)