[FFmpeg-devel] Bug & Patch for ffmpeg.c infinite loop

Creaky Bones whatexercise
Mon Nov 9 09:13:30 CET 2009


Hi Folks,
The following commit to ffmpeg.c (from git) causes ffmpeg to enter an  
infinite loop when processing certain files.
commit 6203d4d38e720078e4be79006a8b4fae37d556bc
Author: michael <michael at 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Date:   Thu Oct 9 18:28:43 2008 +0000

     Limit discontinuity handling to containers that allow  
discontinuities.


Reversing the commit as shown in the following diff using ffmpeg dated  
20091109 stops this infinite loop from occurring.

--- _ffmpeg.c	2009-11-09 16:52:23.000000000 +1100
+++ ffmpeg.c	2009-11-09 16:53:53.000000000 +1100
@@ -2265,8 +2265,7 @@
          }

  //        fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off: 
%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist- 
 >file_index], ist->st->codec->codec_type);
-        if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts !=  
AV_NOPTS_VALUE
-            && (is->iformat->flags & AVFMT_TS_DISCONT)) {
+        if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts !=  
AV_NOPTS_VALUE) {
              int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st- 
 >time_base, AV_TIME_BASE_Q);
              int64_t delta= pkt_dts - ist->next_pts;
              if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE  
|| pkt_dts+1<ist->pts)&& !copy_ts){


When an input file is supplied to ffmpeg that has discontinuities,  
e.g. generated from an older VLC, and the container format does not  
officially support it, then today ffmpeg enters an infinite loop and  
only a kill -9 stops the program. The above fix returns ffmpeg to the  
previous behaviour.

E.g. ffmpeg-6203d4d -i a.asf -s qvga -b 300kb a1.wmv with such an asf  
file will cause the infinite loop to occur.

When tested on ffmpeg (20091109) with the above patch, the asf file is  
successfully processed.

Hope the above helps,

Regards,

Creaky




More information about the ffmpeg-devel mailing list