diff options
author | wm4 <wm4@nowhere> | 2015-05-20 14:24:55 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-05-20 14:24:55 +0200 |
commit | 3e0dae6959d61c053be9811012debde2f17f8ade (patch) | |
tree | 145cb5451f1ad4b8a563cb3af3328ae60e0bb018 /player/video.c | |
parent | 402fe381d7a94c8596d1bed0c8e089b08a298e85 (diff) | |
download | mpv-3e0dae6959d61c053be9811012debde2f17f8ade.tar.bz2 mpv-3e0dae6959d61c053be9811012debde2f17f8ade.tar.xz |
video: better heuristic for timestamp resets
Reduce the default tolerance for timestamp jumps from 60 to 15 seconds.
For .ts files, where ts_resets_possible coming from AVFMT_TS_DISCONT is
set, apply a more sophisticated heuristic. It's clear that such a file
wouldn't have a framerate below, say, 23hz. If the demuxer reports a
lower fps, we allow longer PTS jumps.
This should replace long pauses on discontinuities with .ts files with
at most a short stutter.
Of course, all kinds of things could go wrong anyway if the source is
VFR, or FFmpeg's frame rate detection fails in some other way. I haven't
found such a file yet, though.
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/player/video.c b/player/video.c index d35a9de011..4c8af0f46a 100644 --- a/player/video.c +++ b/player/video.c @@ -559,8 +559,19 @@ static void shift_new_frame(struct MPContext *mpctx) double pts = mpctx->next_frame[0]->pts; if (mpctx->video_pts != MP_NOPTS_VALUE) { frame_time = pts - mpctx->video_pts; - if (frame_time <= 0 || frame_time >= 60) { - // Assume a PTS difference >= 60 seconds is a discontinuity. + double tolerance = 15; + if (mpctx->demuxer->ts_resets_possible) { + // Fortunately no real framerate is likely to go below this. It + // still could be that the file is VFR, but the demuxer reports a + // higher rate, so account for the case of e.g. 60hz demuxer fps + // but 23hz actual fps. + double fps = 23.976; + if (mpctx->d_video->fps > 0 && mpctx->d_video->fps < fps) + fps = mpctx->d_video->fps; + tolerance = 3 * 1.0 / fps; + } + if (frame_time <= 0 || frame_time >= tolerance) { + // Assume a discontinuity. MP_WARN(mpctx, "Invalid video timestamp: %f -> %f\n", mpctx->video_pts, pts); frame_time = 0; |