[FFmpeg-cvslog] avformat/utils: Set the average frame rate from the r_frame_rate if the stream appears to be cfr

Michael Niedermayer git at videolan.org
Mon Apr 28 18:59:03 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Apr 28 18:04:38 2014 +0200| [a215b158152e9fa5f9b625d503cbc66a8286d3d4] | committer: Michael Niedermayer

avformat/utils: Set the average frame rate from the r_frame_rate if the stream appears to be cfr

This permits the average fps to be set in more cases

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a215b158152e9fa5f9b625d503cbc66a8286d3d4
---

 libavformat/utils.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index f91c4fc..26fb0b9 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3023,6 +3023,15 @@ void ff_rfps_calculate(AVFormatContext *ic)
             if (num && (!ref_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(ref_rate)))
                 av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX);
         }
+        if (   !st->avg_frame_rate.num
+            && st->r_frame_rate.num && st->info->rfps_duration_sum
+            && st->info->codec_info_duration <= 0
+            && st->info->duration_count > 2
+            && fabs(1.0 / (av_q2d(st->r_frame_rate) * av_q2d(st->time_base)) - st->info->rfps_duration_sum / (double)st->info->duration_count) <= 1.0
+            ) {
+            av_log(ic, AV_LOG_DEBUG, "Setting avg frame rate based on r frame rate\n");
+            st->avg_frame_rate = st->r_frame_rate;
+        }
 
         av_freep(&st->info->duration_error);
         st->info->last_dts = AV_NOPTS_VALUE;



More information about the ffmpeg-cvslog mailing list