FFmpeg Loudnorm Dual-Pass Options Guide

This article provides a practical overview of the options and parameters used for dual-pass loudness normalization with the loudnorm filter in FFmpeg. It explains how to execute the two-pass process, details the specific measurement options required for the second pass, and provides the command-line syntax needed to achieve precise EBU R128 compliance.

Understanding Dual-Pass Loudnorm

The loudnorm filter in FFmpeg uses the EBU R128 algorithm to normalize audio. While single-pass mode estimates adjustments dynamically, dual-pass mode offers superior quality.

  • Pass 1 analyzes the audio to measure its original loudness characteristics.
  • Pass 2 uses those measurements to apply linear normalization, preventing compression artifacts and ensuring exact target levels.

Pass 1: Analysis Options

In the first pass, you run the filter to analyze the audio without writing a new audio file. The critical option here is print_format=json, which outputs the audio measurements to the terminal.

Example Command

ffmpeg -i input.mp4 -af loudnorm=print_format=json -f null -

Generated Output Parameters

The first pass will output a JSON object containing several "input" measurements. You must save these values to use in the second pass:

  • input_i: The measured integrated loudness of the input file (in LUFS).
  • input_tp: The measured true peak of the input file (in dBTP).
  • input_lra: The measured loudness range of the input file (in LU).
  • input_thresh: The measured threshold of the input file (in LUFS).
  • target_offset: The gain offset required to hit the target.

Pass 2: Normalization Options

In the second pass, you feed the measured values from Pass 1 back into the filter. You must set linear=true to enable dual-pass mode.

Target Parameters (User Defined)

These define your desired output audio standards:

  • I (or integrated_loudness): Target integrated loudness in LUFS (Default: -24.0).
  • TP (or true_peak): Target true peak in dBTP (Default: -2.0).
  • LRA (or loudness_range): Target loudness range in LU (Default: 7.0).

Measured Parameters (From Pass 1 Output)

These parameters represent the actual state of the source audio:

  • measured_i: Set this to the input_i value from Pass 1.
  • measured_tp: Set this to the input_tp value from Pass 1.
  • measured_lra: Set this to the input_lra value from Pass 1.
  • measured_thresh: Set this to the input_thresh value from Pass 1.
  • offset: Set this to the target_offset value from Pass 1.
  • linear: Must be set to true to ensure the filter performs a linear normalization pass instead of dynamic compression.

Example of a Second-Pass Command

Once you have gathered the JSON output from Pass 1, plug the values into the second-pass command as shown below:

ffmpeg -i input.mp4 -af loudnorm=I=-24:TP=-2:LRA=7:measured_i=-15.3:measured_tp=1.2:measured_lra=10.5:measured_thresh=-25.8:offset=0.5:linear=true output.mp4