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
  • Default Values: By default, x265 sets psy-rd to 2.0 and psy-rdoq to 1.0 (active only at RD levels 3 through 6).
  • For High-Grain or Detailed Video: If your source video has a lot of film grain or complex textures, you can increase the values (e.g., psy-rd=2.5:1.5) to prevent the encoder from smoothing out the details.
  • For Clean or Animation Video: For clean sources or 2D animation, lower values (e.g., psy-rd=0.5:0.2 or disabling it entirely with psy-rd=0.0:0.0) are often preferred to avoid introducing artificial ringing artifacts or unnecessary noise.
  • Compatibility: Note that psycho-visual optimizations require an RD (Rate-Distortion) level of 3 or higher to function. If you are using x265 presets that lower the RD level (like ultrafast or superfast), these psy-rd settings will have no effect.