From c23c9e22aef88eede0d3a6b3c63e125a9c7ba8e0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 27 Oct 2017 18:40:33 +0200 Subject: 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. --- sub/lavc_conv.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sub') 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) { -- cgit v1.2.3