[FFmpeg-devel] [PATCH] Fix floating point exception computing duration when no time-base is set

Art Clarke aclarke
Mon Sep 14 06:59:10 CEST 2009


If a user sets a sample-rate on a AVCodecContext before reading a
packet, but no time_base on the AVStream, libavformat crashes with a
div-zero.  Instead it should just fail to compute duration.  Hence,
the attached patch.

- Art

-- 
http://www.xuggle.com/
xu?ggle (z?' gl) v. To freely encode, decode, and experience audio and video.

Use Xuggle to get the power of FFmpeg in Java.
-------------- next part --------------
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c	(revision 19836)
+++ libavformat/utils.c	(working copy)
@@ -788,7 +788,7 @@
 
     if (pkt->duration == 0) {
         compute_frame_duration(&num, &den, st, pc, pkt);
-        if (den && num) {
+        if (den && num && st->time_base.den && st->time_base.num) {
             pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
 
             if(pkt->duration != 0 && s->packet_buffer)



More information about the ffmpeg-devel mailing list