Normalize audio loudness with FFmpeg

Run loudnorm with a target, add -ar 48000, and keep the picture with -c:v copy. For a result closer to the target, measure first and feed the numbers into a second pass. On this quiet film mix (-31.7 LUFS) one pass reached -18.1 LUFS and two passes -16.7, both measured on the output file.

One pass Re-encode

One command, nothing to measure first. Lands short of the target on audio with a wide range.

ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-16:TP=-1.5:LRA=11 -ar 48000 -c:a aac -b:a 192k out.mp4

-18.1 LUFS, loudness range 8.6 LU, true peak -1.2 dBTP. 2 LU short of the target.

Loudness
-18.1 LUFS, from -31.7
True peak
-1.2 dBTP
Run time
2.5 s
Output
23.1 MB
Two pass Re-encode

Measure, then normalize with the measured values. The closest to -16 of any loudnorm run here.

ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-31.89:measured_TP=-7.19:measured_LRA=16.20:measured_thresh=-43.77:offset=2.05:linear=true -ar 48000 -c:a aac -b:a 192k out.mp4

-16.7 LUFS, loudness range 7.8 LU, true peak -1.0 dBTP. The measured values come from the pass-1 command below.

Loudness
-16.7 LUFS, target -16
True peak
-1.0 dBTP
Run time
6.6 s
Output
23.0 MB

Proof

Before and after, on the same scale

Waveforms of the whole 2 minutes, drawn from each file on one linear scale, so heights compare directly. Loudness is integrated LUFS read from each file with ebur128.
in.mp4, untouched
Waveform of the quiet input: short dialogue peaks over a low floor
-31.7 LUFS The film mix as released. Loud moments are rare, most of it sits far below them.
loudnorm, two passes Closest to the target
Waveform after two-pass loudnorm: much taller, with the quiet passages raised the most
-16.7 LUFS 15 LU louder. The range shrank from 16.1 to 7.8 LU, so quiet passages rose more than loud ones.
loudnorm, one pass 2 LU under the target
Waveform after one-pass loudnorm, slightly lower than the two-pass result
-18.1 LUFS The same shape as two passes, 1.4 LU lower.
dynaudnorm No loudness target
Waveform after dynaudnorm: louder, with the contrast between loud and quiet kept
-19.8 LUFS Evens out levels over time but sets no LUFS target. The range came out at 16.7 LU.

Footage: Sintel, © Blender Foundation, CC BY 3.0.

Run it

Run it on Rendobar

Send the same command from your code. The job fetches each input from its URL and returns the output file's URL when it finishes.

job.ts
import { createClient } from "@rendobar/sdk";
const rb = createClient({ apiKey: process.env.RENDOBAR_API_KEY });
const job = await rb.jobs.run({
type: "ffmpeg",
inputs: {
"in.mp4": "https://cdn.rendobar.com/examples/normalize-audio/in.mp4",
},
params: {
command: "ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-31.89:measured_TP=-7.19:measured_LRA=16.20:measured_thresh=-43.77:offset=2.05:linear=true -ar 48000 -c:a aac -b:a 192k out.mp4",
},
});
console.log(job.output.file.url);

Install with npm i @rendobar/sdk. jobs.run() submits and waits, so it returns the finished job in one call.

terminal
curl https://api.rendobar.com/jobs \
-H "Authorization: Bearer $RENDOBAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "ffmpeg",
"inputs": {
"in.mp4": "https://cdn.rendobar.com/examples/normalize-audio/in.mp4"
},
"params": {
"command": "ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-31.89:measured_TP=-7.19:measured_LRA=16.20:measured_thresh=-43.77:offset=2.05:linear=true -ar 48000 -c:a aac -b:a 192k out.mp4"
}
}'

Returns immediately with a job id. Poll GET /jobs/{id} or register a webhook rather than blocking on the request.

Every variant

Pick the command for your case

Each one ran on the same input. The line under it is what came out. Run times are the best of three runs with FFmpeg 8.0 on one desktop machine, so read them as relative.

  1. Measure loudness

    Read only
    ffmpeg -i in.mp4 -vn -af ebur128=peak=true -f null -

    Prints integrated loudness -31.7 LUFS, range 16.1 LU, true peak -7.2 dBFS. Writes no file.

    356 ms run

  2. Get the values for pass 2

    Read only
    ffmpeg -i in.mp4 -vn -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json -f null -

    JSON with input_i -31.89, input_tp -7.19, input_lra 16.20, input_thresh -43.77 and target_offset 2.05. These go into pass 2 as measured_I, measured_TP, measured_LRA, measured_thresh and offset.

    2.2 s run

  3. Normalize to -14 LUFS

    Re-encode
    ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-14:TP=-1:LRA=11 -ar 48000 -c:a aac -b:a 192k out.mp4

    -16.5 LUFS, true peak -0.7 dBTP. One pass falls 2.5 LU short here too.

    2.5 s run 23.0 MB 120.00 s long

  4. Hit the target by allowing less range

    Re-encode
    ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-16:TP=-1.5:LRA=7:measured_I=-31.89:measured_TP=-7.19:measured_LRA=16.20:measured_thresh=-43.77:offset=2.05:linear=true -ar 48000 -c:a aac -b:a 192k out.mp4

    -16.3 LUFS, range 6.6 LU. Closest to -16 on this page, at the cost of more compression.

    2.7 s run 23.0 MB 120.00 s long

  5. Even out the volume with dynaudnorm

    Re-encode
    ffmpeg -i in.mp4 -c:v copy -af dynaudnorm -c:a aac -b:a 192k out.mp4

    -19.8 LUFS, range 16.7 LU, true peak -0.6 dBTP. Louder, with no target to aim at.

    1.9 s run 23.0 MB 120.00 s long

  6. Find the peak level

    Read only
    ffmpeg -i in.mp4 -vn -af volumedetect -f null -

    max_volume: -7.3 dB, mean_volume: -37.0 dB. The highest sample sits 7.3 dB below full scale.

    138 ms run

  7. Raise the volume by a fixed amount

    Re-encode
    ffmpeg -i in.mp4 -c:v copy -af volume=6dB -c:a aac -b:a 192k out.mp4

    -25.8 LUFS, true peak -1.3 dBTP. Every sample 6 dB up, the range unchanged at 16.1 LU.

    1.9 s run 23.0 MB 120.00 s long

Gotchas

Where it goes wrong

Why is my normalized file 96 kHz?

loudnorm outputs 192 kHz audio. Without -ar, FFmpeg hands that to the encoder, and AAC takes the highest rate it supports.

ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-16:TP=-1.5:LRA=11 out.mp4

AAC at 96,000 Hz, and a true peak of -0.1 dBTP against the -1.5 asked for. The same command with -ar 48000 gave 48,000 Hz and -1.2 dBTP.

Always add -ar with loudnorm. Use the input's rate, 48000 for this file.

Why doesn't my file land on -16 LUFS?

On quiet audio with a wide range, loudnorm cannot apply one fixed gain. This mix needed +15.9 dB, which would have pushed its peaks past +8 dBTP. So it falls back to dynamic mode, compresses, and undershoots. Pass 2 says so in its summary:

ffmpeg -i in.mp4 -vn -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-31.89:measured_TP=-7.19:measured_LRA=16.20:measured_thresh=-43.77:offset=2.05:linear=true:print_format=summary -f null -

Normalization Type: Dynamic, Output Integrated: -16.7 LUFS, even with linear=true.

In dynamic mode the measured values change nothing on their own. Only offset does. Pass 2 without offset=2.05 produced a file byte-identical to the one-pass result, at -18.1 LUFS.

  • Copy target_offset from pass 1 into offset. It moved this file from -18.1 to -16.7 LUFS.
  • Allow less range. LRA=7 reached -16.3 LUFS with 6.6 LU of range left.

loudnorm, dynaudnorm or volume?

They do different jobs. On the same file:

  • loudnorm aims at a LUFS target and limits peaks: -16.7 LUFS with two passes. Use it when a platform or spec names a loudness.
  • dynaudnorm evens out level over time with no target: -19.8 LUFS, range kept at 16.7 LU.
  • volume applies one fixed gain: +6 dB gave -25.8 LUFS. Run volumedetect first so the gain does not push the peak past 0 dB.

Related: Mix audio tracks, Convert audio formats, Mute a section, Extract audio.

Your command. Our infrastructure.

Bring your own commands. Run them on scalable CPU and GPU infrastructure, and pay only for compute time.