diff --git a/player/command.c b/player/command.c index 8494903187..9e0f4f64e9 100644 --- a/player/command.c +++ b/player/command.c @@ -6211,7 +6211,7 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, struct mp_decoder_wrapper *dec = track ? track->dec : NULL; if (dec) { mp_decoder_wrapper_control(dec, VDCTRL_REINIT, NULL); - double last_pts = mpctx->last_vo_pts; + double last_pts = mpctx->video_pts; if (last_pts != MP_NOPTS_VALUE) queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0); } diff --git a/player/core.h b/player/core.h index d669d2d031..865b2e9f53 100644 --- a/player/core.h +++ b/player/core.h @@ -369,10 +369,8 @@ typedef struct MPContext { /* timestamp of video frame currently visible on screen * (or at least queued to be flipped by VO) */ double video_pts; + // Last seek target. double last_seek_pts; - // As video_pts, but is not reset when seeking away. (For the very short - // period of time until a new frame is decoded and shown.) - double last_vo_pts; // Frame duration field from demuxer. Only used for duration of the last // video frame. double last_frame_duration; diff --git a/player/loadfile.c b/player/loadfile.c index 4b71d3a999..0ab79bf7a9 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1390,7 +1390,6 @@ static void play_current_file(struct MPContext *mpctx) mpctx->filename = NULL; mpctx->shown_aframes = 0; mpctx->shown_vframes = 0; - mpctx->last_vo_pts = MP_NOPTS_VALUE; mpctx->last_chapter_seek = -2; mpctx->last_chapter_pts = MP_NOPTS_VALUE; mpctx->last_chapter = -2; diff --git a/player/playloop.c b/player/playloop.c index 66ce211322..d1a98be306 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -947,7 +947,6 @@ static void handle_keep_open(struct MPContext *mpctx) if (mpctx->vo_chain) { if (!vo_has_frame(mpctx->video_out)) // EOF not reached normally seek_to_last_frame(mpctx); - mpctx->playback_pts = mpctx->last_vo_pts; } if (opts->keep_open_pause) { if (mpctx->ao) @@ -1075,6 +1074,15 @@ static void handle_playback_time(struct MPContext *mpctx) mpctx->audio_status < STATUS_EOF) { mpctx->playback_pts = playing_audio_pts(mpctx); + } else if (mpctx->video_status == STATUS_EOF && + mpctx->audio_status == STATUS_EOF) + { + double apts = + mpctx->ao_chain ? mpctx->ao_chain->last_out_pts : MP_NOPTS_VALUE; + double vpts = mpctx->video_pts; + double mpts = MP_PTS_MAX(apts, vpts); + if (mpts != MP_NOPTS_VALUE) + mpctx->playback_pts = mpts; } } diff --git a/player/video.c b/player/video.c index 3f5919a25f..5d9879bc51 100644 --- a/player/video.c +++ b/player/video.c @@ -1169,7 +1169,6 @@ void write_video(struct MPContext *mpctx) } mpctx->video_pts = mpctx->next_frames[0]->pts; - mpctx->last_vo_pts = mpctx->video_pts; mpctx->last_frame_duration = mpctx->next_frames[0]->pkt_duration / mpctx->video_speed;