Configure libx265 Psy-RD Strength in FFmpeg

This article explains how to configure the psycho-visual rate-distortion (psy-rd) strength in the libx265 HEVC encoder using FFmpeg. You will learn the specific command-line parameters required to adjust this setting, understand how it affects video quality and compression efficiency, and see practical examples for fine-tuning your video encodes.

Understanding Psy-RD in libx265

Psycho-visual rate-distortion (psy-rd) is a feature in the x265 encoder that biases the encoding process toward human visual perception rather than strict mathematical metrics like PSNR (Peak Signal-to-Noise Ratio). It helps retain fine details, textures, and film grain, preventing the video from looking overly flat or blurry at the cost of a slightly higher bitrate or lower mathematical metric scores.

In libx265, the psycho-visual settings are split into two parts: 1. Psy-RD: Controls the strength of psycho-visual rate-distortion optimizations (mostly affects mode selection). 2. Psy-RDOQ: Controls psycho-visual rate-distortion quantization (adjusts how high-frequency details are quantized).

How to Set Psy-RD in FFmpeg

To configure these settings in FFmpeg, you must pass them via the -x265-params option.

The syntax for setting the psy-rd strength is:

-x265-params psy-rd=strength

Alternatively, you can configure both the primary psy-rd strength and the psy-rdoq strength at the same time using a colon-separated value:

-x265-params psy-rd=psy-rd_strength:psy-rdoq_strength

Basic Encoding Example

Below is a command that sets the psy-rd strength to 1.5 and the psy-rdoq strength to 1.0:

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

Only Modifying the Primary Psy-RD Strength

If you only want to adjust the main psy-rd strength while leaving psy-rdoq at its default (or disabled depending on your subme/rd levels), specify just the single value:

ffmpeg -i input.mp4 -c:v libx265 -crf 22 -x265-params psy-rd=1.8 -c:a copy output.mp4