[vlc-commits] Used the nearest available frame rate in avcodec encoder.

Laurent Aimar git at videolan.org
Wed Oct 5 23:17:40 CEST 2011


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Oct  5 22:40:55 2011 +0200| [bbc85f4b6db94f5d5c81d6e98c43d42931f846ef] | committer: Laurent Aimar

Used the nearest available frame rate in avcodec encoder.

It fixes #1965.

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

 modules/codec/avcodec/encoder.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index db1e58d..d038673 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -402,6 +402,17 @@ int OpenEncoder( vlc_object_t *p_this )
 
         p_context->time_base.num = p_enc->fmt_in.video.i_frame_rate_base;
         p_context->time_base.den = p_enc->fmt_in.video.i_frame_rate;
+        if( p_codec->supported_framerates )
+        {
+            AVRational target = {
+                .num = p_enc->fmt_in.video.i_frame_rate,
+                .den = p_enc->fmt_in.video.i_frame_rate_base,
+            };
+            int idx = av_find_nearest_q_idx(target, p_codec->supported_framerates);
+
+            p_context->time_base.num = p_codec->supported_framerates[idx].den;
+            p_context->time_base.den = p_codec->supported_framerates[idx].num;
+        }
 
         /* Defaults from ffmpeg.c */
         p_context->qblur = 0.5;



More information about the vlc-commits mailing list