[FFmpeg-devel] [PATCH] Allow mpeg encoding with qscale and very low frame rate

James Darnley james.darnley
Thu Sep 2 19:02:47 CEST 2010

Several users have tried to get ffmpeg to encode a series of images
with a frame rate of 1/30, 1/60, etc but when using jpeg output, they
encounter this error.
>[mjpeg @ 01b9cdc0] bitrate tolerance too small for bitrate

If one uses qscale for encoding, the bitrate tolerance has no effect
on the encoding.  If this is correct, then there is no need to error
with this message.

That is what this patch does.

>diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
>index 9f8682c..b48e88f 100644
>--- a/libavcodec/mpegvideo_enc.c
>+++ b/libavcodec/mpegvideo_enc.c
>@@ -356,7 +356,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
>         return -1;
>     }
>-    if(avctx->bit_rate*av_q2d(avctx->time_base) > avctx->bit_rate_tolerance){
>+    if(!s->fixed_qscale && avctx->bit_rate*av_q2d(avctx->time_base) > avctx->bit_rate_tolerance){
>         av_log(avctx, AV_LOG_ERROR, "bitrate tolerance too small for bitrate\n");
>         return -1;
>     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qscale_bitrate_tolerance.diff
Type: application/octet-stream
Size: 558 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100902/9b87fe5c/attachment.obj>

More information about the ffmpeg-devel mailing list