[Libav-user] Changing bit rate while encoding produces a short skip in the video

Joel Ng blood_elves88 at yahoo.com.sg
Thu Mar 30 11:00:28 EEST 2017


Hello,

Following the encode_video.c example on github 
(https://github.com/FFmpeg/FFmpeg/blob/58f24adc05b0ea47c3f7ed5cb9e8d5774e2fbaaf/doc/examples/encode_video.c), 
I have managed to change the bit rate of the encoded video in the 
encoding loop.

However, I have noticed that the video has a short lag or skip when the 
bit rate is changed. Is this behavior expected? I am doing real-time 
live streaming and having this short skip is undesirable.

More details on how I changed bit rate on the fly:
In the encoding loop, I basically called "avcodec_free_context(&c);", 
followed by "c = avcodec_alloc_context3(codec);", setting the other 
parameters (e.g. c->bit_rate, c->width, etc.), and then 
"avcodec_open2(c, codec, NULL)". In short, I called line 66 to 98 in 
encode_video.c once during the encoding loop (line 122 onwards) to 
change the bit rate.

Did I do it correctly? Perhaps I did something unnecessary which 
introduced the skip in the video.

Thanks for the help.

Regards,
Joel


More information about the Libav-user mailing list