diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 73f5dd3a21a39707bf0bca04b65623bab9704607..12487413e4f6168bd5e78204eba843c4af49407a 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -573,8 +573,11 @@ int OpenEncoder( vlc_object_t *p_this )
         else
         {
             p_context->rc_qsquish = 1.0;
-            p_context->rc_max_rate = p_enc->fmt_out.i_bitrate;
-            p_context->rc_min_rate = p_enc->fmt_out.i_bitrate;
+            if( p_sys->i_rc_buffer_size )
+            {
+                p_context->rc_max_rate = p_enc->fmt_out.i_bitrate;
+                p_context->rc_min_rate = p_enc->fmt_out.i_bitrate;
+            }
             p_context->rc_buffer_size = p_sys->i_rc_buffer_size;
             /* This is from ffmpeg's ffmpeg.c : */
             p_context->rc_initial_buffer_occupancy