From a0ec4aebabe1f816cc69e20309981907ba5d1395 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 23 Dec 2015 15:08:58 +0100 Subject: [PATCH] avformat/subtitles: treat negative duration like unknown duration Fixes a specific srt sample, which has an event with negative duration. libavcodec will convert an event with negative duration to an ASS event which will be displayed forever, which is not wanted here. Treat negative duration always as unknown duration instead, and show it until the next subtitle event. --- libavformat/subtitles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index 7c6cd5f353..108f909c84 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -198,7 +198,7 @@ void ff_subtitles_queue_finalize(void *log_ctx, FFDemuxSubtitlesQueue *q) q->sort == SUB_SORT_TS_POS ? cmp_pkt_sub_ts_pos : cmp_pkt_sub_pos_ts); for (i = 0; i < q->nb_subs; i++) - if (q->subs[i].duration == -1 && i < q->nb_subs - 1) + if (q->subs[i].duration < 0 && i < q->nb_subs - 1) q->subs[i].duration = q->subs[i + 1].pts - q->subs[i].pts; if (!q->keep_duplicates)