Ffmpeg (libavcodec) warning: encoded frame too large

I am trying to use libavcodec (ffmpeg) to encode raw pixel data in mp4 format. Everything is going well, and I get a .avi file with decent quality, but sometimes the codec gives a warning "the encoded frame is too big." And when he does, part of some frames (usually the bottom of the frame) looks distorted or everything is messed up. Can anyone tell me when this warning will be given. Below are the settings that I use for the encoder:

qmax = 6;
qmin = 2;
bit_rate = 200000; // if I increase this, I get more warnings. 
width = 1360;
height = 768;
time_base.den = 15; // frames per second
time_base.num = 1;
gop_size = 48;
pix_fmt = PIX_FMT_YUV420P;

Hi,

+3
source share
3 answers

, , ffmpeg 2 . , 1080p 3 , 2 .

, / .

+4

, . rc_buffer_size. , :

ctx->bit_rate = 500000;
ctx->bit_rate_tolerance = 0;
ctx->rc_max_rate = 0;
ctx->rc_buffer_size = 0;
ctx->gop_size = 40;
ctx->max_b_frames = 3;
ctx->b_frame_strategy = 1;
ctx->coder_type = 1;
ctx->me_cmp = 1;
ctx->me_range = 16;
ctx->qmin = 10;
ctx->qmax = 51;
ctx->scenechange_threshold = 40;
ctx->flags |= CODEC_FLAG_LOOP_FILTER;
ctx->me_method = ME_HEX;
ctx->me_subpel_quality = 5;
ctx->i_quant_factor = 0.71;
ctx->qcompress = 0.6;
ctx->max_qdiff = 4;
ctx->directpred = 1;
ctx->flags2 |= CODEC_FLAG2_FASTPSKIP;
+2

In the code example, I found something like:

outbuf_size = 100000;
outbuf = malloc(outbuf_size);

[...]

out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture);

Pressing outbuf_sizefor a greater degree eliminates the problem.

+1
source

Source: https://habr.com/ru/post/1768056/


All Articles