1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 00:02:13 +00:00

video: don't wait for last video frame in the normal case

Even though the timing logic is correct, it tends to mess with looping
videos and such in unappreciated ways.

It also has to be admitted that most file formats seem not to properly
define the duration of the last video frame (or libavformat does not
export it in a useful way), so whether or not we should use the demuxer
reported framerate for the last frame is questionable. (Still, why would
you essentially just discard the last frame?)

The timing logic is kept, but disabled for video with "normal" FPS
values. In particular, we want to keep it for displaying images, which
implicitly set the frame duration to 1 second by reporting 1 FPS. It's
also good for slide shows with mf://.

Fixes #2745.
This commit is contained in:
wm4 2016-01-22 00:24:49 +01:00
parent 50c701574d
commit 657dd4b807

View File

@ -1142,8 +1142,9 @@ static void calculate_frame_duration(struct MPContext *mpctx)
if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0) if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
duration = pts1 - pts0; duration = pts1 - pts0;
} else { } else {
// E.g. last frame on EOF. // E.g. last frame on EOF. Only use it if it's significant.
duration = demux_duration; if (demux_duration >= 0.1)
duration = demux_duration;
} }
// The following code tries to compensate for rounded Matroska timestamps // The following code tries to compensate for rounded Matroska timestamps
@ -1207,8 +1208,11 @@ void write_video(struct MPContext *mpctx, double endpts)
if (r == VD_EOF) { if (r == VD_EOF) {
int prev_state = mpctx->video_status; int prev_state = mpctx->video_status;
mpctx->video_status = mpctx->video_status = STATUS_EOF;
vo_still_displaying(vo) ? STATUS_DRAINING : STATUS_EOF; if (mpctx->num_past_frames > 0 && mpctx->past_frames[0].duration > 0) {
if (vo_still_displaying(vo))
mpctx->video_status = STATUS_DRAINING;
}
mpctx->delay = 0; mpctx->delay = 0;
mpctx->last_av_difference = 0; mpctx->last_av_difference = 0;
MP_DBG(mpctx, "video EOF (status=%d)\n", mpctx->video_status); MP_DBG(mpctx, "video EOF (status=%d)\n", mpctx->video_status);