video: use a better vbv-bufsize & correct software bitrate calculation

* Increase vbv-bufsize to 1/10 of requested bitrate. The previous value
  was too low, which was resulting in poor encoding quality and failure to
  stabilize at the requested bitrate. Setting to 1/10 of bitrate is a
  good compromise, as it avoids quality loss but also prevents bandwidth
  spikes far above the bitrate/vbv-maxrate.
* With vbv-bufsize set to a more appropriate value, testing shows that
  the average bitrate vs client-requested bandwidth overshoots by ~20%.
  Adjust for this scenario in the software encoding case only.
This commit is contained in:
Conn O'Griofa 2021-12-08 22:24:49 +00:00 committed by Christophe Fajardo
parent ac7fcfe056
commit 1b6bf8fa34

View File

@ -930,9 +930,9 @@ std::optional<session_t> make_session(const encoder_t &encoder, const config_t &
}
if(video_format[encoder_t::CBR]) {
auto bitrate = config.bitrate * 1000;
auto bitrate = config.bitrate * (hardware ? 1000 : 800); // software bitrate overshoots by ~20%
ctx->rc_max_rate = bitrate;
ctx->rc_buffer_size = bitrate / config.framerate;
ctx->rc_buffer_size = bitrate / 10;
ctx->bit_rate = bitrate;
ctx->rc_min_rate = bitrate;
}