From 3f5920ae5d0dbacb3bd863d0cc9f9619f5ce13f5 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 14 Jun 2017 00:43:31 -0700 Subject: [PATCH] deps/media-playback: Fix AV_NOPTS_VALUE being used as timestamp With certain media files (wmv in particular), the very last frame will have a timestamp of AV_NOPTS_VALUE. This could cause the media to stick on that frame indefinitely. Instead, use the estimated next timestamp that was calculated in the previous frame. --- deps/media-playback/media-playback/decode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/deps/media-playback/media-playback/decode.c b/deps/media-playback/media-playback/decode.c index 017c1beb7..bd8f1efeb 100644 --- a/deps/media-playback/media-playback/decode.c +++ b/deps/media-playback/media-playback/decode.c @@ -320,9 +320,13 @@ bool mp_decode_next(struct mp_decode *d) if (d->frame_ready) { int64_t last_pts = d->frame_pts; - d->frame_pts = av_rescale_q(d->frame->best_effort_timestamp, - d->stream->time_base, - (AVRational){1, 1000000000}); + if (d->frame->best_effort_timestamp == AV_NOPTS_VALUE) + d->frame_pts = d->next_pts; + else + d->frame_pts = av_rescale_q( + d->frame->best_effort_timestamp, + d->stream->time_base, + (AVRational){1, 1000000000}); int64_t duration = d->frame->pkt_duration; if (!duration) @@ -331,6 +335,7 @@ bool mp_decode_next(struct mp_decode *d) duration = av_rescale_q(duration, d->stream->time_base, (AVRational){1, 1000000000}); + d->last_duration = duration; d->next_pts = d->frame_pts + duration; }