normalize-sfx
v1.0.2
Published
Normalize WAV file loudness to EBU R128 standards using FFmpeg
Maintainers
Readme
normalize-sfx
Batch-normalize .wav sound effects using FFmpeg's two-pass loudnorm filter.
Requirements
Install
npm install -g normalize-sfxUsage
normalize-sfx [directory] [options]If no directory is given, the current working directory (.) is used.
Scans for .wav files in the given directory (non-recursive — subdirectories are not visited).
Options
| Flag | Short | Default | Description |
|---|---|---|---|
| --lufs <n> | -l | -16 | Target integrated loudness (LUFS) |
| --tp <n> | -t | -1 | Target true peak (dBTP) |
| --lra <n> | -r | 11 | Target loudness range (LU) |
| --concurrency <n> | -c | 3 | Max parallel FFmpeg processes |
| --output <path> | -o | (none — written alongside originals) | Output directory for normalized files |
| --dry-run | -d | off | List files, skip processing |
Output naming
- Without
--output: Files are written alongside the originals with a_norm.wavsuffix (e.g.boom_norm.wav). Originals are never overwritten. - With
--output: Files are written to the specified directory with their original names preserved. A warning is shown if an output file already exists. - With
--dry-run: Files are listed with their output paths — either alongside the originals (no--output) or inside the custom directory (with--output). No processing occurs.
Examples
# Default targets, current directory
normalize-sfx
# Custom LUFS, specific folder
normalize-sfx ./assets/sfx --lufs -18
# Custom output directory
normalize-sfx ./sounds -o ./normalized
# Preview without processing
normalize-sfx ./sounds -d
# Aggressive concurrency
normalize-sfx ./sounds -c 8How It Works
Pass 1 — Analysis: FFmpeg runs loudnorm in measurement mode (print_format=json), outputting the file's current loudness stats to stderr. These values (input_i, input_tp, input_lra, input_thresh) are parsed.
Pass 2 — Normalization: FFmpeg runs again with the measured values injected via measured_* parameters, applying linear=true:offset=0.0. When --output is specified the file is written there; otherwise it is written alongside the original.
Safety
- FFmpeg check: The tool verifies FFmpeg is available on
$PATHbefore processing. - Filesystem confinement: All file paths are confined to the working directory — symlinks are skipped and path escape attempts are rejected.
- Error isolation: A failure processing one file does not stop the rest. A non-zero exit code is returned if any file fails.
- Per-pass timeout: Each FFmpeg pass times out after 300 seconds.
About EduTherapy
This tool is developed by EduTherapy (a brand of Talim Shifa Studio), specializing in digital transformation for education and healthcare sectors through Progressive Web Apps.
- 🌐 Website: https://eduth.pro/
- 📧 Contact: [email protected]
License
MIT
