From 183af9d72eac25efc4b6a6a92249963cec5793f0 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 20 Oct 2016 11:20:23 -0700 Subject: player: speed up audio/video re-sync when there is a huge delay when there is a huge delay between audio/video sync, it can take a really long time to converge back. this speeds up the resync time by increasing the max_change allowed per iteration. Signed-off-by: wm4 --- player/video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index ff72f92d8e..21babe016e 100644 --- a/player/video.c +++ b/player/video.c @@ -729,8 +729,9 @@ static void adjust_sync(struct MPContext *mpctx, double v_pts, double frame_time double av_delay = a_pts - v_pts; double change = av_delay * 0.1; + double factor = fabs(av_delay) < 0.3 ? 0.1 : 0.4; double max_change = opts->default_max_pts_correction >= 0 ? - opts->default_max_pts_correction : frame_time * 0.1; + opts->default_max_pts_correction : frame_time * factor; if (change < -max_change) change = -max_change; else if (change > max_change) -- cgit v1.2.3 From 90b968a67a73473d615e2ee6135756573d0da6f2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 26 Oct 2016 20:43:03 +0200 Subject: player: show subtitles on VO if --force-window is used If a VO is created, but no video is playing (i.e. --force-window is used), then until now no subtitles were shown. This is because VO subtitle display normally depends on video frame timing. If there are no video frames, there can be no subtitles. Change this and add some code to handle this situation specifically. Set a subtitle PTS manually and request VO redrawing manually, which gets the subtitles rendered somehow. This is kind of shaky. The subtitles are essentially sampled at arbitrary times (such as when new audio data is decoded and pushed to the AO, or on user interaction). To make a it slightly more consistent, force a completely arbitrary minimum FPS of 10. Other solutions (such as creating fake video) would be more intrusive or would require VO-level API changes. Fixes #3684. --- player/video.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index 21babe016e..7a76f4dc8e 100644 --- a/player/video.c +++ b/player/video.c @@ -482,6 +482,9 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src) update_window_title(mpctx, true); + // Undo what the subtitle path does if mpctx->vo_chain is unset. + osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE); + struct vo_chain *vo_c = talloc_zero(NULL, struct vo_chain); mpctx->vo_chain = vo_c; vo_c->log = mpctx->log; -- cgit v1.2.3 From c4d6fcbb021a3e3d0c62d6f60ec88aaea602b054 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 Nov 2016 13:01:46 +0100 Subject: player: make sure non-video subtitle rendering is reset if video resumes If video reaches EOF, subtitle timing will be switched to timing without video frames. This means it calls osd_set_force_video_pts() and overrides the PTS of whatever video frame is current (since the video frame's PTS has nothing to do with the current playback position anymore). This was not reset when seeking back into video. Subtitles wouldn't show up, or if there was a subtitle displayed, it would get stuck with it. In particular, this could happen even if EOF was only temporary (such as with --keep-open). Fix this by clearing the override PTS whenever a video frame is shown. Fixes #3770. --- player/video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index 7a76f4dc8e..847a5b56d9 100644 --- a/player/video.c +++ b/player/video.c @@ -482,9 +482,6 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src) update_window_title(mpctx, true); - // Undo what the subtitle path does if mpctx->vo_chain is unset. - osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE); - struct vo_chain *vo_c = talloc_zero(NULL, struct vo_chain); mpctx->vo_chain = vo_c; vo_c->log = mpctx->log; @@ -1427,6 +1424,9 @@ void write_video(struct MPContext *mpctx) mpctx->time_frame -= get_relative_time(mpctx); update_avsync_before_frame(mpctx); + // Enforce timing subtitles to video frames. + osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE); + if (!update_subtitles(mpctx, mpctx->next_frames[0]->pts)) { MP_VERBOSE(mpctx, "Video frame delayed due waiting on subtitles.\n"); return; -- cgit v1.2.3