Before you start

FFmpeg upstream dated 7.1.6 and 8.0.4 on December 1, 2026. This exercise uses the existing loudnorm filter. The exercise target is not a universal platform requirement.

What you’ll make
A stereo 48 kHz, 24-bit PCM WAV and a JSON technical report for a −16 LUFS, ≤ −1.5 dBTP exercise.
What you’ll need
Python 3, FFmpeg with loudnorm, ffprobe, and an authorized stereo WAV (or the synthetic fixture).

Step by step

  1. Measure the input

    Measure before changing the mix. Preserve the original. Capture integrated loudness, loudness range, true peak, threshold and offset from the filter’s JSON. Nonfinite data usually means an unsuitable or quiet source and should stop the workflow.

  2. Normalize from measured values

    Feed those values back into loudnorm and export a separate stereo 48 kHz PCM 24-bit WAV. Prefer linear mode but record the actual mode from FFmpeg, which may fall back to dynamic when constraints conflict.

  3. Remeasure the actual output

    Measure the final exported WAV independently, using the input measurements of that audit run. Require −16 ±0.5 LUFS and no higher than −1.5 dBTP for this exercise. If producing a different final codec, remeasure its actual delivery file.

  4. Listen and sign off

    Listen for distortion, pumping and intelligibility at comparable playback levels. If listening is unavailable, leave that review outstanding. Do not approve an output that failed its numerical checks.

Commands

cat > master_loudness.py <<'PYTHON'
#!/usr/bin/env python3
import sys, subprocess, json, re
from pathlib import Path
src,dst,report=map(Path,sys.argv[1:4])
assert not dst.exists() and not report.exists(),"Use new output paths"
def run(args):
    return subprocess.run(args,check=True,capture_output=True,text=True)
def loudness(path):
    result=run(["ffmpeg","-hide_banner","-nostdin","-i",str(path),"-map","0:a:0","-af","loudnorm=I=-16:LRA=11:TP=-1.5:print_format=json","-f","null","-"])
    return json.loads(re.findall(r'\{[^{}]*"input_i"[^{}]*\}',result.stderr)[-1])
before=loudness(src)
fields={k:float(before[v]) for k,v in dict(measured_I="input_i",measured_LRA="input_lra",measured_TP="input_tp",measured_thresh="input_thresh",offset="target_offset").items()}
if not all(-99 < n < 99 for n in fields.values()):
    raise SystemExit("Input is silent, too short, or has invalid loudness")
params="loudnorm=I=-16:LRA=11:TP=-1.5:linear=true:print_format=json:"+":".join(f"{k}={v}" for k,v in fields.items())
result=run(["ffmpeg","-hide_banner","-nostdin","-n","-i",str(src),"-map","0:a:0","-af",params,"-ar","48000","-c:a","pcm_s24le",str(dst)])
mode=json.loads(re.findall(r'\{[^{}]*"input_i"[^{}]*\}',result.stderr)[-1])["normalization_type"]
after=loudness(dst)
stream=json.loads(run(["ffprobe","-v","error","-select_streams","a:0","-show_entries","stream=codec_name,channels,sample_rate","-of","json",str(dst)]).stdout)["streams"][0]
passed=(stream == {"codec_name":"pcm_s24le","sample_rate":"48000","channels":2}) and abs(float(after["input_i"])+16)<=0.5 and float(after["input_tp"])<=-1.5
report.write_text(json.dumps({"fixture":"input audio","before":before,"mode":mode,"delivered":after,"stream":stream,"passed":passed},indent=2)+"\n")
print(report.read_text())
if not passed or stream != {'codec_name':'pcm_s24le','sample_rate':'48000','channels':2}: raise SystemExit("Delivery failed re-measurement; do not publish.")
PYTHON
# Optional synthetic stereo input; use an owned, balanced stereo WAV instead for your mix.
ffmpeg -v error -n -f lavfi -i 'sine=frequency=880:sample_rate=48000:duration=12' -ac 2 -c:a pcm_s24le own-mix.wav
python3 master_loudness.py own-mix.wav mastered.wav loudness-qa.json
ffprobe -v error -show_entries stream=codec_name,sample_rate,channels:format=duration -of json mastered.wav

Sign-in & permissions

No account, model download, plugin, token or API. Existing Python and FFmpeg installations suffice; pause for approval before a missing system dependency is installed.

No agent plugin, registered skill, or MCP connector is required for this workflow.

Prompt for your agent

Use with: A terminal-enabled agent such as Codex or Claude Code, using a local POSIX shell or translating quoting for PowerShell.

Copy the whole prompt into a supported agent. After any manual step, tell the same agent to continue from that step.

Use a clean project folder for this workflow: Master an audio mix with two-pass FFmpeg loudness checks. Supported setup: A terminal-enabled agent such as Codex or Claude Code, using a local POSIX shell or translating quoting for PowerShell.. Start from the original documentation: https://ffmpeg.org/ffmpeg-filters.html#loudnorm.

1. SET UP
Start in a new folder, verify python3, ffmpeg, ffprobe and loudnorm. Save the supplied standard-library starter. If a system tool is missing, pause and give the owner the official download instructions.

Documented commands or code reference (respect the comments and replace placeholders before running individual commands):
cat > master_loudness.py <<'PYTHON'
#!/usr/bin/env python3
import sys, subprocess, json, re
from pathlib import Path
src,dst,report=map(Path,sys.argv[1:4])
assert not dst.exists() and not report.exists(),"Use new output paths"
def run(args):
    return subprocess.run(args,check=True,capture_output=True,text=True)
def loudness(path):
    result=run(["ffmpeg","-hide_banner","-nostdin","-i",str(path),"-map","0:a:0","-af","loudnorm=I=-16:LRA=11:TP=-1.5:print_format=json","-f","null","-"])
    return json.loads(re.findall(r'\{[^{}]*"input_i"[^{}]*\}',result.stderr)[-1])
before=loudness(src)
fields={k:float(before[v]) for k,v in dict(measured_I="input_i",measured_LRA="input_lra",measured_TP="input_tp",measured_thresh="input_thresh",offset="target_offset").items()}
if not all(-99 < n < 99 for n in fields.values()):
    raise SystemExit("Input is silent, too short, or has invalid loudness")
params="loudnorm=I=-16:LRA=11:TP=-1.5:linear=true:print_format=json:"+":".join(f"{k}={v}" for k,v in fields.items())
result=run(["ffmpeg","-hide_banner","-nostdin","-n","-i",str(src),"-map","0:a:0","-af",params,"-ar","48000","-c:a","pcm_s24le",str(dst)])
mode=json.loads(re.findall(r'\{[^{}]*"input_i"[^{}]*\}',result.stderr)[-1])["normalization_type"]
after=loudness(dst)
stream=json.loads(run(["ffprobe","-v","error","-select_streams","a:0","-show_entries","stream=codec_name,channels,sample_rate","-of","json",str(dst)]).stdout)["streams"][0]
passed=(stream == {"codec_name":"pcm_s24le","sample_rate":"48000","channels":2}) and abs(float(after["input_i"])+16)<=0.5 and float(after["input_tp"])<=-1.5
report.write_text(json.dumps({"fixture":"input audio","before":before,"mode":mode,"delivered":after,"stream":stream,"passed":passed},indent=2)+"\n")
print(report.read_text())
if not passed or stream != {'codec_name':'pcm_s24le','sample_rate':'48000','channels':2}: raise SystemExit("Delivery failed re-measurement; do not publish.")
PYTHON
# Optional synthetic stereo input; use an owned, balanced stereo WAV instead for your mix.
ffmpeg -v error -n -f lavfi -i 'sine=frequency=880:sample_rate=48000:duration=12' -ac 2 -c:a pcm_s24le own-mix.wav
python3 master_loudness.py own-mix.wav mastered.wav loudness-qa.json
ffprobe -v error -show_entries stream=codec_name,sample_rate,channels:format=duration -of json mastered.wav

2. PAUSE FOR ME IF NEEDED
For a host install, sign-in, permission screen, or model download that needs my consent, stop and tell me the exact app, control and what will be authorized. Do not enter passwords, OTPs or secrets in chat. Resume after I confirm.

3. BUILD THE FIRST RESULT
On an owned audio file or clearly marked synthetic stereo fixture, normalize to −16 ±0.5 LUFS and at most −1.5 dBTP using the supplied local script. Measure separately after the output, return the WAV and JSON, record actual mode and format, and stop on technical failures. If you can listen, check distortion and intelligibility. Do not modify the original or publish.

4. CHECK THE RESULT
Report integrated LUFS, true peak, filter mode, codec, sample rate, channels and duration. Check the encoded output rather than relying on the filter’s predicted measurement. Give me the actual file paths and anything that still needs a manual action. Do not publish or make a purchase.

Sources