Opened 4 years ago
Last modified 3 months ago
#10209 reopened defect
EBUR128 and LOUDNORM filters compute LRA differently
| Reported by: | hsn | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | 7.1 | Keywords: | LRA, ebur128 |
| Cc: | Zulianino | Blocked By: | |
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
Summary of the bug:
How to reproduce:
ffmpeg -i song192k.mp4 -af ebur128,loudnorm=print_format=summary -f null -
Outputs:
[Parsed_ebur128_0 @ 000001f413d21a40] Summary:
Integrated loudness:
I: -14.0 LUFS
Threshold: -24.1 LUFS
Loudness range:
LRA: 3.6 LU
Threshold: -33.9 LUFS
LRA low: -15.6 LUFS
LRA high: -12.0 LUFS
[Parsed_loudnorm_1 @ 000001f413fc4e40]
Input Integrated: -14.2 LUFS
Input True Peak: +0.1 dBTP
Input LRA: 5.9 LU
Input Threshold: -24.3 LUFS
One LRA is 5.9 and second is 3.6. Song analysed by https://youlean.co/file-loudness-meter/ returns:
Momentary Max = -9.81 LUFS Short Term Max = -11.50 LUFS Integrated = -14.00 LUFS
LRA definition is here: https://tech.ebu.ch/docs/tech/tech3342v2_0.pdf
Change History (13)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
I uploaded source song but its just normal:
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 139 kb/s (default)
comment:3 by , 4 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Invalid command. You need to run separate filters, as ebur128 by default use input sample rate and does not upsample to 192kHz.
Also no sample to reproduce.
comment:6 by , 4 years ago
File uploaded to https://streams.videolan.org/upload/
I don't believe its specific to file, here it computes different LRA for any file.
upsample to 192k doesn't change LRA.
ffmpeg -i song192k.mp4 -af aresample=192k,ebur128,loudnorm=print_format=summary -f null -
Software from Nugen audio we use in radio reports LRA 3.5, ILA -14.0 so it seems like EBUR128 filter is correct.
comment:7 by , 4 years ago
How long in seconds are files?
Too short files are known to give invalid results.
comment:10 by , 4 years ago
Intersting, but simply first decoding aac to wav (be it 24 bit or 16 bit, or whatever) allows one to produce
Input True Peak: +0.0 dBTP
and not (I also get that when I decode using aac):
Input True Peak: +0.1 dBTP
That happens because
ffmpeg -c:a aac_fixed -i palestine-song192k.mp4 -c:a pcm_s24le -af ebur128,loudnorm=print_format=summary -f null -
(aac_fixed) is not the default, LOLZ.
There is also an issue that AAC is not gapless in the end, but that should not matter much. But will check gapless stuff. Gapless stuff does not affect this, nice!
comment:11 by , 16 months ago
i have same issue.
using ebur128 i have a measured integrated of -24.0 and LRA of 8.5
ffmpeg -i 20250724_094226_1fefa141_TEST_MIXSC2353_5FR_pre_ffmpeg.mxf -hide_banner -af ebur128 -f null -
Integrated loudness:
I: -24.0 LUFS
Threshold: -34.5 LUFS
Loudness range:
LRA: 8.5 LU
Threshold: -44.0 LUFS
LRA low: -30.0 LUFS
LRA high: -21.5 LUFS
Sample peak:
Peak: -10.8 dBFS
while using loudnorm I have integrated of -24.59 and LRA of 9.7
ffmpeg -i 20250724_094226_1fefa141_TEST_MIXSC2353_5FR_pre_ffmpeg.mxf -af loudnorm=print_format=json -f null -
{
"input_i" : "-24.59",
"input_tp" : "-10.82",
"input_lra" : "9.70",
"input_thresh" : "-35.23",
"output_i" : "-24.85",
"output_tp" : "-10.75",
"output_lra" : "6.30",
"output_thresh" : "-35.26",
"normalization_type" : "dynamic",
"target_offset" : "0.85"
}
using broadcast software to analyze the files, results are equal to ebur128 filter
is someone able to check this?
comment:12 by , 16 months ago
| Cc: | added |
|---|---|
| Resolution: | invalid |
| Status: | closed → reopened |
| Version: | 5.1.2 → 7.1 |
comment:13 by , 3 months ago
This ticket stalled on "you have not posted expected/correct LRA at all" and on the absence of a reproducible sample. Both are answerable using the EBU's own conformance signals, which have published expected values and tolerances and can be generated from the specification rather than uploaded.
EBU Tech 3341 Table 1 defines eight minimum-requirement test signals. Five are synthetic 1 kHz stereo sine tones with a stated expected integrated loudness and a ±0.1 LUFS tolerance. Generating them and running both filters, on ffmpeg 8.0.1:
| Tech 3341 case | signal | expected I | ebur128 | loudnorm |
|---|---|---|---|---|
| 1 | 20 s @ -23.0 dBFS | -23.0 ±0.1 | -23.000 | -23.05 |
| 2 | 20 s @ -33.0 dBFS | -33.0 ±0.1 | -33.000 | -33.05 |
| 3 | 10 s @ -36, 60 s @ -23, 10 s @ -36 | -23.0 ±0.1 | -23.021 | -23.07 |
| 4 | 10 s @ -72, 10 s @ -36, 60 s @ -23, 10 s @ -36, 10 s @ -72 | -23.0 ±0.1 | -23.021 | -23.07 |
| 5 | 20 s @ -26, 20.1 s @ -20, 20 s @ -26 | -23.0 ±0.1 | -22.985 | -23.14 |
ebur128 is within tolerance on all five, worst error 0.021 LU. loudnorm is within tolerance on 1 to 4 and outside it on case 5, at 0.14 LU.
The signals are 20 to 90 seconds long, which should address the earlier concern about short inputs giving invalid results.
Which case fails, and why that is informative
Case 5 is the relative-gating test. Cases 3 and 4 place their quiet segments at -36 and -72 dBFS, far enough down that the absolute gate at -70 LKFS and the -10 LU relative gate exclude them unambiguously. Case 5 puts its quiet segments at -26 dBFS against a -20 dBFS loud segment, close enough to the relative gate that the gating decision changes the answer. The 20.1 s duration of the middle segment appears deliberate for the same reason.
loudnorm passes every case that does not exercise relative gating and fails the one that does. That suggests the divergence is in the gating rather than in K-weighting or block accumulation, which would also be consistent with the LRA difference originally reported here, since LRA uses a different gate (-20 LU) over the same block statistics.
There also appears to be a smaller constant offset independent of gating: loudnorm reads 0.05 low on case 1, a single constant tone with no gating decision to make at all.
A third implementation for reference
pyloudnorm 0.2.0, an independent pure-Python BS.1770 implementation, on the same files:
case1 I = -23.0347 LUFS case5 I = -23.0201 LUFS
Both within tolerance. On case 5 it agrees with ebur128 to 0.035 LU and differs from loudnorm by 0.12 LU.
Why the two filters can differ at all
libavfilter contains two separate EBU R128 implementations:
libavfilter/ebur128.candebur128.h, based on Jan Kokemüller's libebur128, used byaf_loudnorm.cthroughff_ebur128_add_frames_doubleandff_ebur128_loudness_globallibavfilter/f_ebur128.candf_ebur128.h, the standaloneebur128filter
So the two filters are not two views of one measurement; they are two implementations of one standard shipped in one library. That explains how they can disagree, and suggests the LRA difference reported here and the integrated-loudness difference above are likely the same root cause rather than two separate bugs.
Reproducing
No upload needed. This writes the five files:
import numpy as np, wave SR, F = 48000, 1000.0 def tone(db, dur): n = int(round(SR * dur)) return 10.0 ** (db / 20.0) * np.sin(2 * np.pi * F * np.arange(n) / SR) def write(path, mono): st = np.column_stack([mono, mono]) # in phase, both channels pcm = (np.clip(st, -1, 1) * (2**31 - 1)).astype(np.int32) with wave.open(path, 'wb') as w: w.setnchannels(2); w.setsampwidth(4); w.setframerate(SR) w.writeframes(pcm.tobytes()) write("case1.wav", tone(-23.0, 20.0)) write("case2.wav", tone(-33.0, 20.0)) write("case3.wav", np.concatenate([tone(-36,10), tone(-23,60), tone(-36,10)])) write("case4.wav", np.concatenate([tone(-72,10), tone(-36,10), tone(-23,60), tone(-36,10), tone(-72,10)])) write("case5.wav", np.concatenate([tone(-26,20), tone(-20,20.1), tone(-26,20)]))
Measuring:
ffmpeg -i case5.wav -af "ebur128=metadata=1,ametadata=mode=print" -f null - # -22.985 ffmpeg -i case5.wav -af loudnorm=print_format=json -f null - # -23.14
The ebur128 filter's summary prints to one decimal place, which rounds -22.985 to -23.0 and hides differences of this size; the metadata output above gives three decimals.
Tested on macOS with ffmpeg 8.0.1. I have not checked other platforms, though since the discrepancy is a gating decision rather than a floating-point margin I would not expect it to be platform-dependent.
EBU Tech 3341 is freely available at https://tech.ebu.ch/docs/tech/tech3341.pdf; the test signal definitions are in Table 1.



What is song192k.mp4? eac3? Then you need to set -drc_scale 0.