Browse code

avformat/mux: Check for and remove invalid packet durations

Fixes assertion failure
Fixes Ticket3575

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit dc6a17cf74a90e41d70ea1753cdb70c0a5b2ced8)

Michael Niedermayer authored on 2014/04/23 13:04:50
Showing 1 changed files
... ...
@@ -435,6 +435,12 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
435 435
     av_dlog(s, "compute_pkt_fields2: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
436 436
             av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index);
437 437
 
438
+    if (pkt->duration < 0 && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
439
+        av_log(s, AV_LOG_WARNING, "Packet with invalid duration %d in stream %d\n",
440
+               pkt->duration, pkt->stream_index);
441
+        pkt->duration = 0;
442
+    }
443
+
438 444
     /* duration field */
439 445
     if (pkt->duration == 0) {
440 446
         ff_compute_frame_duration(&num, &den, st, NULL, pkt);