Configure libx265 Psy-Visual Quantization in FFmpeg

This article explains how to configure and fine-tune the psycho-visual quantization settings in the FFmpeg libx265 encoder. You will learn the specific command-line parameters used to adjust psycho-visual rate-distortion (psy-RD) and psycho-visual rate-distortion optimization quantization (psy-RDOQ) to optimize the perceived visual quality of your HEVC/H.265 video encodes.

Understanding Psycho-Visual Quantization in x265

Psycho-visual quantization adjustments prevent the encoder from discarding fine details, textures, and film grain in favor of flat, blurry surfaces. In libx265, this behavior is primarily controlled by two parameters:

Configuring the Parameters in FFmpeg

Because these options are specific to the libx265 library, they must be passed to FFmpeg using the -x265-params argument, separated by colons.

The syntax for configuring both settings is as follows:

ffmpeg -i input.mp4 -c:v libx265 -crf 22 -x265-params psy-rd=1.5:psy-rdoq=1.0 output.mp4

Adjusting these values depends on the type of content you are encoding:

Example: Encoding Film with Grain Preservation

To preserve film grain and high-frequency textures in a high-definition movie, you can use higher psycho-visual settings:

ffmpeg -i input.mkv -c:v libx265 -crf 18 -preset slow -x265-params psy-rd=2.0:psy-rdoq=1.5 output.mkv

Example: Encoding Clean Animation

For flat, clean animated content, lower psycho-visual settings prevent the encoder from wasting bitrate on artificial noise:

ffmpeg -i animation.mkv -c:v libx265 -crf 20 -preset slow -x265-params psy-rd=0.5:psy-rdoq=0.2 output.mkv