summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-27 18:40:33 +0200
committerwm4 <wm4@nowhere>2017-10-27 18:40:33 +0200
commitc23c9e22aef88eede0d3a6b3c63e125a9c7ba8e0 (patch)
tree7b814a103391d0ed08bef442022712bb2c828baf
parent3c21694ff0728952c94705c3c8623f0c7f40a44a (diff)
downloadmpv-c23c9e22aef88eede0d3a6b3c63e125a9c7ba8e0.tar.bz2
mpv-c23c9e22aef88eede0d3a6b3c63e125a9c7ba8e0.tar.xz
lavc_conv: clamp timestamps to positive, fixes idiotic ffmpeg issue
In some cases, demux_mkv will detect a start time slightly above 0, but there might still be a subtitle starting at exactly 0. When the player rebases the timestamps to assumed start time, the subtitle will have a slightly negative timestamp in the end. libavcodec's subtitle converter turns this into a larger number due to underflow. Fix by clamping subtitles always to 0, which may or may not be what you want. At least it fixes #5047.
-rw-r--r--sub/lavc_conv.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c
index 0f3b18e0fa..843da42ca7 100644
--- a/sub/lavc_conv.c
+++ b/sub/lavc_conv.c
@@ -237,6 +237,8 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet)
avsubtitle_free(&priv->cur);
mp_set_av_packet(&pkt, packet, &avctx->time_base);
+ if (pkt.pts < 0)
+ pkt.pts = 0;
if (strcmp(priv->codec, "webvtt-webm") == 0) {
if (parse_webvtt(&pkt, &parsed_pkt) < 0) {