mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 09:32:40 +00:00
mplayer: try to handle PTS forward jumps
Raw MPEG streams can contain PTS discontinuities. While the playback core has obvious code for handling PTS going backward, PTS going forward was as far as I can see not handled. This can be an issue with DVD playback. This wasn't caught earlier, because DVD playback was just recently switched to demux_lavf, which implies -no-correct-pts mode. This mode doesn't use PTS in the same way as the normal playback mode, and as such was too primitive to be affected by this issue. Use the following heuristic to handle PTS forward jumps: if the PTS difference between two frames is higher than 10 seconds, consider it a reset. (Also, use MSGL_WARN for the PTS discontinuity warnings.) In this particular case, the MPEG stream was going from pts=304510857 to pts=8589959849 according to ffprobe (raw timestamps), which seems a bit strange. Note that this heuristic breaks if the source video has unusually high frame times. For example Rooster_Teeth_Podcast_191.m4a, an audio file with a slide show encoded as MJPEG video track.
This commit is contained in:
parent
6c3a4ba9f9
commit
4a5d1f2d44
@ -2692,7 +2692,7 @@ static double update_video(struct MPContext *mpctx, double endpts)
|
||||
if (sh_video->last_pts == MP_NOPTS_VALUE)
|
||||
sh_video->last_pts = sh_video->pts;
|
||||
else if (sh_video->last_pts > sh_video->pts) {
|
||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Decreasing video pts: %f < %f\n",
|
||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Decreasing video pts: %f < %f\n",
|
||||
sh_video->pts, sh_video->last_pts);
|
||||
/* If the difference in pts is small treat it as jitter around the
|
||||
* right value (possibly caused by incorrect timestamp ordering) and
|
||||
@ -2703,6 +2703,11 @@ static double update_video(struct MPContext *mpctx, double endpts)
|
||||
sh_video->last_pts = sh_video->pts;
|
||||
else
|
||||
sh_video->pts = sh_video->last_pts;
|
||||
} else if (sh_video->pts >= sh_video->last_pts + 60) {
|
||||
// Assume a PTS difference >= 60 seconds is a discontinuity.
|
||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Jump in video pts: %f -> %f\n",
|
||||
sh_video->last_pts, sh_video->pts);
|
||||
sh_video->last_pts = sh_video->pts;
|
||||
}
|
||||
double frame_time = sh_video->pts - sh_video->last_pts;
|
||||
sh_video->last_pts = sh_video->pts;
|
||||
|
Loading…
Reference in New Issue
Block a user