Skip to main content

reference_frames

Function reference_frames 

Source
pub fn reference_frames(settings: &RustCaptureSettings) -> u32
Expand description

Size the CBR VBV/HRD buffer so rate control has enough slack to hold quality steady without letting end-to-end latency drift upward.

The size is expressed as a multiple of one frame’s bit budget (bitrate_bps / fps) rather than a fixed byte count so a live bitrate or framerate change rescales the buffer with it, preserving the same latency behavior at every operating point.

The 1.5-frame default holds for hardware rate control too: a one-frame buffer measured on NVENC (gpu_bench_cbr_policy, a V100) ran an 8 Mbit/s H.264 session at 13.3 to 13.7 Mbit/s on scene cuts at the same PSNR, made the frame after a single cut larger (408 against 288 kbit) and bought nothing on steady content. The overshoot is the quarter-resolution first pass misjudging a scene cut with no buffer left to absorb the miss (gpu_bench_cbr_rate_control): full-resolution two-pass holds a one-frame buffer at 1.5 ms more per frame, single-pass halves the overshoot at a lower PSNR, and the GOP target and quantizer ceiling change nothing. HEVC holds either buffer.

§Arguments

  • bitrate_bps - Target bitrate in bits per second.
  • fps - Target frames per second.
  • keyframe_interval_s - Seconds between scheduled keyframes; <= 0 for infinite GOP.
  • multiplier - Explicit buffer multiplier; <= 0 selects the policy default (1.5 on infinite GOP, 3 when keyframe interval is active).

§Returns

VBV buffer size in bits, clamped to [1, u32::MAX]. The most frames an H.264 or H.265 session keeps for reference (video_reference_frames).