[FFmpeg-devel] [PATCH v4 2/9] lavc/libopenh264enc: add default gop size and bit rate

Martin Storsjö martin at martin.st
Mon Apr 27 22:28:28 EEST 2020


On Wed, 15 Apr 2020, Linjie Fu wrote:

> It would be 200kbps bitrate with gop size = 12 by default
> which generated too many IDR frames in rather low bit rate.
> The quality would be poor.
>
> Set these default values according to vaapi encoder, and
> use 2Mbps bitrate if user doesn't set it explicitly as
> nvenc sugguested.
>
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
> libavcodec/libopenh264enc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index c7ae5b1..57313b1 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -132,7 +132,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>     param.fMaxFrameRate              = 1/av_q2d(avctx->time_base);
>     param.iPicWidth                  = avctx->width;
>     param.iPicHeight                 = avctx->height;
> -    param.iTargetBitrate             = avctx->bit_rate;
> +    param.iTargetBitrate             = avctx->bit_rate > 0 ? avctx->bit_rate : 2*1000*1000;
>     param.iMaxBitrate                = FFMAX(avctx->rc_max_rate, avctx->bit_rate);
>     param.iRCMode                    = RC_QUALITY_MODE;
>     // QP = 0 is not well supported, so default to (1, 51)
> @@ -335,6 +335,8 @@ static int svc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
> }
> 
> static const AVCodecDefault svc_enc_defaults[] = {
> +    { "b",         "0"     },
> +    { "g",         "120"   },
>     { "qmin",      "-1"    },

Why do you hardcode a value for g here, but put the default bitrate value 
in the code above? Wouldn't it be clearer to have both defaults here at 
the same place?

// Martin



More information about the ffmpeg-devel mailing list