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

Laurent Aimar git at videolan.org
Wed Oct 5 23:28:33 CEST 2011


vlc/vlc-1.1 | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Oct  5 22:40:55 2011 +0200| [ca07c9bf9e855cde4f43043b7cc5ca675b8e6181] | committer: Jean-Baptiste Kempf

Used the nearest available frame rate in avcodec encoder.

It fixes #1965.
(cherry picked from commit bbc85f4b6db94f5d5c81d6e98c43d42931f846ef)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 14c5e05..1be7a0e 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -404,6 +404,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