[FFmpeg-cvslog] mpegvideo enc: choose VBV buffer size for mpeg1/ 2 when none is specified instead of failing
Michael Niedermayer
git at videolan.org
Wed Oct 24 00:51:45 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Oct 24 00:03:06 2012 +0200| [1856162caa912a4a845b7caff51c9e2dff3d39d9] | committer: Michael Niedermayer
mpegvideo enc: choose VBV buffer size for mpeg1/2 when none is specified instead of failing
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1856162caa912a4a845b7caff51c9e2dff3d39d9
---
libavcodec/mpegvideo_enc.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d777072..00b0d03 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -403,6 +403,18 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
s->loop_filter = !!(s->flags & CODEC_FLAG_LOOP_FILTER);
+ if (avctx->rc_max_rate && !avctx->rc_buffer_size) {
+ switch(avctx->codec_id) {
+ case AV_CODEC_ID_MPEG1VIDEO:
+ case AV_CODEC_ID_MPEG2VIDEO:
+ avctx->rc_buffer_size = FFMAX(avctx->rc_max_rate, 15000000) * 112L / 15000000 * 16384;
+ break;
+ }
+ if (avctx->rc_buffer_size) {
+ av_log(avctx, AV_LOG_INFO, "Automatically choosing VBV buffer size of %d kbyte\n", avctx->rc_buffer_size/8192);
+ }
+ }
+
if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) {
av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or neither must be specified\n");
if (avctx->rc_max_rate && !avctx->rc_buffer_size)
More information about the ffmpeg-cvslog
mailing list