CBR vs CRF
Overview
LCEVC encodes enhanced streams in Constant Bitrate mode (CBR) or (either uncapped or capped) Constant Rate Factor (pCRF) mode.
Rate control window type and length
The LCEVC rate control can work according to different modes: “chunk” (default) or “rolling window”. When in streaming “chunk” mode, the rate controller resets the leaky bucket fill up level at the beginning of each streaming chunk, to avoid unnecessary influence from one chunk to the next (e.g. making a chunk slightly smaller than the target bitrate just because the previous one was slightly bigger, or vice versa). When in “rolling window” mode, instead, the leaky bucket fill up level is never reset.
“Chunk” mode is recommended for ABR chunk-based streaming, while “rolling window” mode is recommended for low-latency video as well as for tests involving short self-similar sequences.
“Chunk” mode is active by default, so there is no need to specify the corresponding setting within eil_params (rc_pcrf_window_type=chunk).
To activate the “rolling window” mode, the following command should be used within eil_params
:
rc_pcrf_window_type=rolling
By default, the rate control window length is two GOPs, but you can specify a different length in frames with the following command within eil_params
:
rc_pcrf_window_duration_frame=<number of frames in a window>
CBR
CBR ensures that the same bitrate is maintained throughout the clip, as is required for many streaming video systems. This is achieved in FFmpeg by specifying the target bitrate with –b:v
parameter, as in the following example (CBR at 2 Mbps).
Note: By default, in FFmpeg, -b:v
bitrate is interpreted as bps and a suffix for kbps and Mbps must be used, e.g. -b:v 2000k specifies that bitrate = 2 Mbps.
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 -b:v 2000k output.ts
In LCEVC, a CBR stream can have a base following a different rate control paradigm. In LCEVC, the base encoder rate control can work with either a CBR base layer (default), or a CRF base layer.
rc_pcrf_base_rc_mode=cbr
(default) is recommended for most codecs. By default, LCEVC will also adapt the base bitrate target dynamically, based on the characteristics of the sequence.rc_pcrf_base_rc_mode=crf
may also be used, with base codecs that do support CRF (e.g. x264, x265).
To activate the “CBR base” with a fixed bitrate target for the base (not recommended for best visual quality), the following command should be used: rc_pcrf_base_reconfig_mode=0
.
The FFmpeg command for a 2 Mbps CBR, with default CBR base, is as follows:
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 -b:v 2000k -eil_params output.ts
The FFmpeg command for a 2 Mbps CBR, with CRF base, is modified as follows:
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 -b:v 2000k -eil_params "rc_pcrf_base_rc_mode=crf" output.ts
pCRF, capped and uncapped
pCRF, which is the V-Nova LCEVC equivalent of x264’s CRF, aims to ensure that a certain quality factor is maintained throughout the clip. Lower pCRF values mean less compression and higher quality, at the expense of larger file sizes. The pCRF value is a floating-point fractional number with a meaning similar to x264’s CRF (e.g. typical value range 20-36), controlling the overall quality of base + enhancement. To activate pCRF, the following command is used, where X is the chosen pCRF value: rc_pcrf=X
pCRF uncapped: For uncapped pCRF, the bitrate parameter must be set to 0 or left unspecified, as per the following command line example, in which pCRF 30 is specified.
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 [-b:v 0] -eil_params "rc_pcrf=30" output.ts
pCRF capped: For capped pCRF, the bitrate parameter must be set to the desired maximum bitrate (or cap), as per the following command line example, in which pCRF 30 is specified with a maximum of 3,000kbps (3Mbps). Specifying the LCEVC minimum bitrate to 0 will allow the base to use the entire cap if required. The base mode must also be set manually to CRF in this scenario.
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 [-b:v 3000] -eil_params "rc_pcrf=30;rc_pcrf_min_bitrate=0;rc_pcrf_base_rc_mode=crf" output.ts
QP Min
The QP (Quantization Parameter) controls the amount of compression for every macroblock in a frame. Large values mean that there will be higher quantization, more compression, and lower quality. Lower values mean the opposite. The full range available for QP is 0-51.
By setting the min QP value this will stop the rate control using a value below X. This needs to be done within the eil_params
.
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 -eil_params "rc_pcrf_base_min_qp=14;" output.ts
QP Max
Setting the max QP value will stop the rate control using a value above X. This needs to be done within the eil_params
.
ffmpeg.exe -i input.mp4 -c:v lcevc_h264 -base_encoder x264 -eil_params "qp-max=32" output.ts
Important note: Not all base plugins support this field.
Last updated
Was this helpful?