How to Set B-Frame Bias in FFmpeg libx265

This article explains how to configure the B-frame bias in the FFmpeg libx265 encoder. You will learn the specific command-line parameters required to adjust B-frame decision-making, understand how different bias values affect video compression and quality, and view practical command examples to implement in your encoding workflow.

To configure the B-frame bias in libx265, you must use the -x265-params option in FFmpeg to pass the b-bias argument directly to the underlying x265 encoder.

Understanding B-Frame Bias

B-frames (bi-predictive pictures) are highly compressed frames that refer to both preceding and succeeding frames. The B-frame bias setting controls how aggressively the encoder chooses to use B-frames over P-frames (predictive frames).

FFmpeg Command Syntax

To set the B-frame bias, append b-bias=value to the -x265-params flag.

Example 1: Increasing B-Frame Usage

To encourage the encoder to use more B-frames for better compression:

ffmpeg -i input.mp4 -c:v libx265 -x265-params b-bias=30 output.mp4

Example 2: Decreasing B-Frame Usage

To discourage the encoder from using B-frames to preserve high-motion detail:

ffmpeg -i input.mp4 -c:v libx265 -x265-params b-bias=-20 output.mp4

Combining with Maximum B-Frames

The B-frame bias works in tandem with the maximum allowed number of B-frames. If the maximum number of B-frames is set to 0, B-frame bias will have no effect. You can define both the maximum B-frames (bframes) and the bias (b-bias) together inside the -x265-params option by separating them with a colon:

ffmpeg -i input.mp4 -c:v libx265 -x265-params bframes=6:b-bias=15 output.mp4