rtpenc: base max_frames_per_packet on avg_frame_rate, not codec timebase
authorAnton Khirnov <anton@khirnov.net>
Thu, 29 May 2014 05:58:35 +0000 (07:58 +0200)
committerAnton Khirnov <anton@khirnov.net>
Wed, 18 Jun 2014 13:03:16 +0000 (15:03 +0200)
Fall back to 1 (which is what is used for most cases anyway) when the
framerate is not set.

libavformat/rtpenc.c

index 83167eba9c3aef04a17cd244eba9f201e97bd327..0027abd421ae82035ffe84f45c8abb713010fecb 100644 (file)
@@ -165,7 +165,12 @@ static int rtp_write_header(AVFormatContext *s1)
         }
         if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
             /* FIXME: We should round down here... */
-            s->max_frames_per_packet = av_rescale_q(s1->max_delay, (AVRational){1, 1000000}, st->codec->time_base);
+            if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0) {
+                s->max_frames_per_packet = av_rescale_q(s1->max_delay,
+                                                        (AVRational){1, 1000000},
+                                                        av_inv_q(st->avg_frame_rate));
+            } else
+                s->max_frames_per_packet = 1;
         }
     }