How to Configure b-intra in FFmpeg libx265

This article provides a quick overview and step-by-step guide on how to configure the b-intra option in the libx265 encoder using FFmpeg. You will learn what the b-intra feature is, how it affects your video encodes, and the precise command-line syntax required to enable or disable it.

What is b-intra?

In the HEVC/H.265 video compression standard, B-frames (bi-directional predicted frames) typically reference past and future frames to compress video data. Enabling the b-intra option allows the libx265 encoder to use intra-coded blocks (I-blocks) within these B-frames.

By allowing intra-prediction inside B-frames, the encoder can choose to code block areas as static image data when temporal prediction (referencing other frames) is inefficient, such as during fast motion, camera cuts, or sudden lighting changes. This generally improves visual quality and compression efficiency, though it slightly increases encoding complexity and CPU usage.

How to Configure b-intra in FFmpeg

Because b-intra is an encoder-specific parameter for libx265, it is not a direct FFmpeg flag. Instead, you must pass it to the encoder using the -x265-params option.

The b-intra option accepts a boolean value: * b-intra=1 (or b-intra=true) to enable it. * b-intra=0 (or b-intra=false) to disable it.

Command Example: Enabling b-intra

To encode a video with b-intra enabled, use the following FFmpeg command:

ffmpeg -i input.mp4 -c:v libx265 -x265-params b-intra=1 output.mp4

Command Example: Disabling b-intra

If you want to disable the feature to speed up encoding times slightly, use this command:

ffmpeg -i input.mp4 -c:v libx265 -x265-params b-intra=0 output.mp4

Combining b-intra with Other Parameters

If you are already passing other options to the libx265 encoder, you can combine them within the -x265-params argument by separating each option with a colon (:).

Here is an example configuring the Constant Rate Factor (CRF), the keyframe interval (keyint), and enabling b-intra:

ffmpeg -i input.mp4 -c:v libx265 -crf 22 -x265-params b-intra=1:keyint=240 output.mp4