ffmpeg-normalize 1.31.3__tar.gz → 1.32.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/CHANGELOG.md +25 -0
  2. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/LICENSE +1 -1
  3. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/PKG-INFO +35 -563
  4. ffmpeg_normalize-1.32.0/README.md +85 -0
  5. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/__main__.py +17 -1
  6. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/_ffmpeg_normalize.py +18 -3
  7. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/_media_file.py +110 -0
  8. ffmpeg_normalize-1.32.0/ffmpeg_normalize/_version.py +1 -0
  9. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/PKG-INFO +35 -563
  10. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/setup.cfg +1 -10
  11. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/test/test.mp4 +0 -0
  12. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/test/test.py +12 -0
  13. ffmpeg_normalize-1.31.3/README.md +0 -638
  14. ffmpeg_normalize-1.31.3/ffmpeg_normalize/_version.py +0 -1
  15. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/__init__.py +0 -0
  16. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/_cmd_utils.py +0 -0
  17. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/_errors.py +0 -0
  18. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/_logger.py +0 -0
  19. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/_streams.py +0 -0
  20. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize/py.typed +0 -0
  21. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/SOURCES.txt +0 -0
  22. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/dependency_links.txt +0 -0
  23. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/entry_points.txt +0 -0
  24. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/not-zip-safe +0 -0
  25. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/requires.txt +0 -0
  26. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/ffmpeg_normalize.egg-info/top_level.txt +0 -0
  27. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/setup.py +0 -0
  28. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/test/out.mp4 +0 -0
  29. {ffmpeg_normalize-1.31.3 → ffmpeg_normalize-1.32.0}/test/test.wav +0 -0
@@ -1,6 +1,31 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v1.32.0 (2025-05-07)
5
+
6
+ * Docs: update contributing guide.
7
+
8
+ * Docs: convert options to headlines.
9
+
10
+ * Docs: update ffmpeg guide.
11
+
12
+ * Fix: do not write replaygain tags if dry run is used.
13
+
14
+ * Fix: flake8 no longer used.
15
+
16
+ * Fix docs links.
17
+
18
+ * Add mkdocs documentation.
19
+
20
+ * Update python in dockerfile.
21
+
22
+ * Remove years from copyright.
23
+
24
+ * Dev stuff.
25
+
26
+ * Add replaygain support.
27
+
28
+
4
29
  ## v1.31.3 (2025-04-14)
5
30
 
6
31
  * Swap NUL to os.devnull.
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2017 Werner Robitza
3
+ Copyright (c) Werner Robitza
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ffmpeg_normalize
3
- Version: 1.31.3
3
+ Version: 1.32.0
4
4
  Summary: Normalize audio via ffmpeg
5
5
  Home-page: https://github.com/slhck/ffmpeg-normalize
6
6
  Author: Werner Robitza
@@ -38,557 +38,29 @@ A utility for batch-normalizing audio using ffmpeg.
38
38
 
39
39
  This program normalizes media files to a certain loudness level using the EBU R128 loudness normalization procedure. It can also perform RMS-based normalization (where the mean is lifted or attenuated), or peak normalization to a certain target level.
40
40
 
41
- Batch processing of several input files is possible, including video files.
41
+ ## Features
42
42
 
43
- **A very quick how-to:**
43
+ - EBU R128 loudness normalization
44
+ - RMS-based normalization
45
+ - Peak normalization
46
+ - Video file support
47
+ - Docker support
48
+ - Python API
49
+
50
+ ## 🚀 Quick Start
44
51
 
45
52
  1. Install a recent version of [ffmpeg](https://ffmpeg.org/download.html)
46
53
  2. Run `pip3 install ffmpeg-normalize`
47
54
  3. Run `ffmpeg-normalize /path/to/your/file.mp4`
48
- 4. Done! 🎧 (the file will be in a folder called `normalized`)
49
-
50
- Read on for more info.
51
-
52
- **Contents:**
53
-
54
- - [Requirements](#requirements)
55
- - [ffmpeg](#ffmpeg)
56
- - [Installation](#installation)
57
- - [Shell Completions](#shell-completions)
58
- - [Usage with Docker](#usage-with-docker)
59
- - [High LeveL Introduction](#high-level-introduction)
60
- - [Basic Usage](#basic-usage)
61
- - [Examples](#examples)
62
- - [Detailed Options](#detailed-options)
63
- - [File Input/Output](#file-inputoutput)
64
- - [General](#general)
65
- - [Normalization](#normalization)
66
- - [EBU R128 Normalization](#ebu-r128-normalization)
67
- - [Audio Encoding](#audio-encoding)
68
- - [Other Encoding Options](#other-encoding-options)
69
- - [Input/Output Format](#inputoutput-format)
70
- - [Environment Variables](#environment-variables)
71
- - [API](#api)
72
- - [FAQ](#faq)
73
- - [My output file is too large?](#my-output-file-is-too-large)
74
- - [What options should I choose for the EBU R128 filter? What is linear and dynamic mode?](#what-options-should-i-choose-for-the-ebu-r128-filter-what-is-linear-and-dynamic-mode)
75
- - [The program doesn't work because the "loudnorm" filter can't be found](#the-program-doesnt-work-because-the-loudnorm-filter-cant-be-found)
76
- - [Should I use this to normalize my music collection?](#should-i-use-this-to-normalize-my-music-collection)
77
- - [Why are my output files MKV?](#why-are-my-output-files-mkv)
78
- - [I get a "Could not write header for output file" error](#i-get-a-could-not-write-header-for-output-file-error)
79
- - [The conversion does not work and I get a cryptic ffmpeg error!](#the-conversion-does-not-work-and-i-get-a-cryptic-ffmpeg-error)
80
- - [What are the different normalization algorithms?](#what-are-the-different-normalization-algorithms)
81
- - [Couldn't I just run `loudnorm` with ffmpeg?](#couldnt-i-just-run-loudnorm-with-ffmpeg)
82
- - [What about speech?](#what-about-speech)
83
- - [After updating, this program does not work as expected anymore!](#after-updating-this-program-does-not-work-as-expected-anymore)
84
- - [Can I buy you a beer / coffee / random drink?](#can-i-buy-you-a-beer--coffee--random-drink)
85
- - [Related Tools and Articles](#related-tools-and-articles)
86
- - [Contributors](#contributors)
87
- - [License](#license)
88
-
89
- -------------
90
-
91
- ## Requirements
92
-
93
- You need Python 3.9 or higher, and ffmpeg.
94
-
95
- ### ffmpeg
96
-
97
- - ffmpeg 5.x is required, ffmpeg 6.x is recommended (it fixes [a bug for short files](https://github.com/slhck/ffmpeg-normalize/issues/87))
98
- - Download a [static build](https://ffmpeg.org/download.html) for your system
99
- - Place the `ffmpeg` executable in your `$PATH`, or specify the path to the binary with the `FFMPEG_PATH` environment variable in `ffmpeg-normalize`
100
-
101
- For instance, under Linux:
102
-
103
- ```bash
104
- wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
105
- mkdir -p ffmpeg
106
- tar -xf ffmpeg-release-amd64-static.tar.xz -C ffmpeg --strip-components=1
107
- sudo cp ffmpeg/ffmpeg /usr/local/bin
108
- sudo cp ffmpeg/ffprobe /usr/local/bin
109
- sudo chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
110
- ```
111
-
112
- For Windows, follow [this guide](https://www.wikihow.com/Install-FFmpeg-on-Windows).
113
-
114
- For macOS and Linux, you can also use [Homebrew](https://brew.sh):
115
-
116
- ```bash
117
- brew install ffmpeg
118
- ```
119
-
120
- Note that using distribution packages (e.g., `apt install ffmpeg`) is not recommended, as these are often outdated.
121
-
122
- ## Installation
123
-
124
- For Python 3 and pip:
125
-
126
- ```bash
127
- pip3 install ffmpeg-normalize
128
- ```
129
-
130
- Or download this repository, then run `pip3 install .`.
131
-
132
- To later upgrade to the latest version, run `pip3 install --upgrade ffmpeg-normalize`.
133
-
134
- ### Shell Completions
135
-
136
- This tool provides shell completions for bash and zsh. To install them:
137
-
138
- <!--
139
- Note to self: Generate the shtab ones with:
140
-
141
- shtab --shell=bash -u ffmpeg_normalize.__main__.create_parser > completions/ffmpeg-normalize-shtab.bash
142
- shtab --shell=zsh -u ffmpeg_normalize.__main__.create_parser > completions/ffmpeg-normalize-shtab.zsh
143
-
144
- but these are not properly working yet.
145
- -->
146
-
147
- #### Bash
148
-
149
- If you have [`bash-completion`](https://github.com/scop/bash-completion) installed, you can just copy your new completion script to the `/usr/local/etc/bash_completion.d` directory.
150
-
151
- ```bash
152
- curl -L https://raw.githubusercontent.com/slhck/ffmpeg-normalize/master/completions/ffmpeg-normalize-completion.bash \
153
- -o /usr/local/etc/bash_completion.d/ffmpeg-normalize
154
- ```
155
-
156
- Without bash-completion, you can manually install the completion script:
157
-
158
- ```bash
159
- # create completions directory if it doesn't exist
160
- mkdir -p ~/.bash_completions.d
161
-
162
- # download and install completion script
163
- curl -L https://raw.githubusercontent.com/slhck/ffmpeg-normalize/master/completions/ffmpeg-normalize-completion.bash \
164
- -o ~/.bash_completions.d/ffmpeg-normalize
165
-
166
- # source it in your ~/.bashrc
167
- echo 'source ~/.bash_completions.d/ffmpeg-normalize' >> ~/.bashrc
168
- ```
169
-
170
- #### Zsh
171
-
172
- Download the completion script and place it in the default `site-functions` directory:
173
-
174
- ```bash
175
- curl -L https://raw.githubusercontent.com/slhck/ffmpeg-normalize/master/completions/ffmpeg-normalize.zsh \
176
- -o /usr/local/share/zsh/site-functions/
177
- ```
178
-
179
- You may choose any other directory that is in your `$FPATH` variable.
180
- Make sure your `.zshrc` file contains `autoload -Uz compinit && compinit`.
181
-
182
- ## Usage with Docker
183
-
184
- You can use the pre-built image from Docker Hub:
185
-
186
- ```bash
187
- docker run -v "$(pwd):/tmp" -it slhck/ffmpeg-normalize
188
- ```
189
-
190
- Alternatively, download this repository and run
191
-
192
- ```bash
193
- docker build -t ffmpeg-normalize .
194
- ```
195
-
196
- Then run the container with:
197
-
198
- ```bash
199
- docker run -v "$(pwd):/tmp" -it ffmpeg-normalize
200
- ```
201
-
202
- This will mount your current directory to the `/tmp` directory inside the container. Everything else works the same way as if you had installed the program locally. For example, to normalize a file:
203
-
204
- ```bash
205
- docker run -v "$(pwd):/tmp" -it ffmpeg-normalize /tmp/yourfile.mp4 -o /tmp/yourfile-normalized.wav
206
- ```
207
-
208
- You will then find the normalized file in your current directory.
209
-
210
- ## High LeveL Introduction
211
-
212
- Please read this section for a high level introduction.
213
-
214
- **What does the program do?**
215
-
216
- The program takes one or more input files and, by default, writes them to a folder called `normalized`, using an `.mkv` container. All audio streams will be normalized so that they have the same (perceived) volume according to the EBU R128 standard. This is done by analyzing the audio streams and applying a filter to bring them to a target level. Under the hood, the program uses ffmpeg's `loudnorm` filter to do this.
217
-
218
- **How do I specify the input?**
219
-
220
- Just give the program one or more input files as arguments. It works with most media files, including video files.
221
-
222
- **How do I specify the output?**
223
-
224
- You don't have to specify an output file name (the default is `normalized/<input>.mkv`), but if you want to override it, you can specify one output file name for each input file with the `-o` option. In this case, the container format (e.g. `.wav`) will be inferred from the file name extension that you've given.
225
-
226
- Example:
227
-
228
- ```bash
229
- ffmpeg-normalize 1.wav 2.wav -o 1-normalized.wav 2-normalized.wav
230
- ```
231
-
232
- Note that if you don't specify the output file name for an input file, the container format will be MKV, and the output will be written to `normalized/<input>.mkv`. The reason for choosing the MKV container is that it can handle almost any codec combination.
233
-
234
- Using the `-ext` option, you can supply a different output extension common to all output files, e.g. `-ext m4a`. However, you need to make sure that the container supports the codecs used for the output (see below).
235
-
236
- **What will get normalized?**
237
-
238
- By default, all streams from the input file will be written to the output file. For example, if your input is a video with two language tracks and a subtitle track, both audio tracks will be normalized independently. The video and subtitle tracks will be copied over to the output file.
239
-
240
- **How will the normalization be done?**
241
-
242
- The normalization will be performed according to the EBU R128 algorithm with the [`loudnorm` filter](https://ffmpeg.org/ffmpeg-filters.html#loudnorm) from FFmpeg, which was [originally written by Kyle Swanson](https://k.ylo.ph/2016/04/04/loudnorm.html). It will bring the audio to a specified target level. This ensures that multiple files normalized with this filter will have the same perceived loudness.
243
-
244
- **What codec is chosen?**
245
-
246
- The default audio encoding method is uncompressed PCM (`pcm_s16le`) to avoid introducing compression artifacts. This will result in a much higher bitrate than you might want, for example if your input files are MP3s.
247
-
248
- Some containers (like MP4) also cannot handle PCM audio. If you want to use such containers and/or keep the file size down, use `-c:a` and specify an audio codec (e.g., `-c:a aac` for ffmpeg's built-in AAC encoder).
249
-
250
- ## Basic Usage
251
-
252
- Supply one or more input files, and optionally, output file names:
253
-
254
- ```bash
255
- ffmpeg-normalize input [input ...][-h][-o OUTPUT [OUTPUT ...]] [options]
256
- ```
257
-
258
- Example:
259
-
260
- ```bash
261
- ffmpeg-normalize 1.wav 2.wav -o 1-normalized.m4a 2-normalized.m4a -c:a aac -b:a 192k
262
- ```
263
-
264
- For more information on the options (`[options]`) available, run `ffmpeg-normalize -h`, or read on.
265
-
266
- ## Examples
267
-
268
- [Read the examples on the wiki.](https://github.com/slhck/ffmpeg-normalize/wiki/examples)
269
-
270
- ## Detailed Options
271
-
272
- ### File Input/Output
273
-
274
- - `input`: Input media file(s)
275
-
276
- - `-o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]`: Output file names.
277
-
278
- Will be applied per input file.
279
-
280
- If no output file name is specified for an input file, the output files
281
- will be written to the default output folder with the name `<input>.<ext>`, where `<ext>` is the output extension (see `-ext` option).
282
-
283
- Example: `ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav`
284
-
285
- - `-of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER`: Output folder (default: `normalized`)
286
-
287
- This folder will be used for input files that have no explicit output name specified.
288
-
289
- ### General
290
-
291
- - `-f, --force`: Force overwrite existing files
292
-
293
- - `-d, --debug`: Print debugging output
294
-
295
- - `-v, --verbose`: Print verbose output
296
-
297
- - `-q, --quiet`: Only print errors
298
-
299
- - `-n, --dry-run`: Do not run normalization, only print what would be done
300
-
301
- - `-pr`, `--progress`: Show progress bar for files and streams
302
-
303
- - `--version`: Print version and exit
304
-
305
- ### Normalization
306
-
307
- - `-nt {ebu,rms,peak}, --normalization-type {ebu,rms,peak}`: Normalization type (default: `ebu`).
308
-
309
- EBU normalization performs two passes and normalizes according to EBU R128.
310
-
311
- RMS-based normalization brings the input file to the specified RMS level.
312
-
313
- Peak normalization brings the signal to the specified peak level.
314
-
315
- - `-t TARGET_LEVEL, --target-level TARGET_LEVEL`: Normalization target level in dB/LUFS (default: -23).
316
-
317
- For EBU normalization, it corresponds to Integrated Loudness Target in LUFS. The range is -70.0 - -5.0.
318
-
319
- Otherwise, the range is -99 to 0.
320
-
321
- - `-p, --print-stats`: Print loudness statistics for both passes formatted as JSON to stdout.
322
-
323
- ### EBU R128 Normalization
324
-
325
- - `-lrt LOUDNESS_RANGE_TARGET, --loudness-range-target LOUDNESS_RANGE_TARGET`: EBU Loudness Range Target in LUFS (default: 7.0).
326
-
327
- Range is 1.0 - 50.0.
328
-
329
- - `--keep-loudness-range-target`: Keep the input loudness range target to allow for linear normalization.
330
-
331
- - `--keep-lra-above-loudness-range-target`: Keep input loudness range above loudness range target.
332
-
333
- Can be used as an alternative to `--keep-loudness-range-target` to allow for linear normalization.
334
-
335
- - `-tp TRUE_PEAK, --true-peak TRUE_PEAK`: EBU Maximum True Peak in dBTP (default: -2.0).
336
-
337
- Range is -9.0 - +0.0.
338
-
339
- - `--offset OFFSET`: EBU Offset Gain (default: 0.0).
340
-
341
- The gain is applied before the true-peak limiter in the first pass only. The offset for the second pass will be automatically determined based on the first pass statistics.
342
-
343
- Range is -99.0 - +99.0.
344
-
345
- - `--lower-only`: Whether the audio should not increase in loudness.
346
-
347
- If the measured loudness from the first pass is lower than the target loudness then normalization pass will be skipped for the measured audio source.
348
-
349
- - `--auto-lower-loudness-target`: Automatically lower EBU Integrated Loudness Target.
350
-
351
- Automatically lower EBU Integrated Loudness Target to prevent falling back to dynamic filtering.
352
-
353
- Makes sure target loudness is lower than measured loudness minus peak loudness (input_i - input_tp) by a small amount.
354
-
355
- - `--dual-mono`: Treat mono input files as "dual-mono".
356
-
357
- If a mono file is intended for playback on a stereo system, its EBU R128 measurement will be perceptually incorrect. If set, this option will compensate for this effect. Multi-channel input files are not affected by this option.
55
+ 4. Done! 🎧 (the normalized file will be called `normalized/file.mkv`)
358
56
 
359
- - `--dynamic`: Force dynamic normalization mode.
57
+ ## 📓 Documentation
360
58
 
361
- Instead of applying linear EBU R128 normalization, choose a dynamic normalization. This is not usually recommended.
59
+ Check out our [documentation](https://slhck.info/ffmpeg-normalize/) for more info!
362
60
 
363
- Dynamic mode will automatically change the sample rate to 192 kHz. Use `-ar`/`--sample-rate` to specify a different output sample rate.
61
+ ## 🤝 Contributors
364
62
 
365
- ### Audio Encoding
366
-
367
- - `-c:a AUDIO_CODEC, --audio-codec AUDIO_CODEC`: Audio codec to use for output files.
368
-
369
- See `ffmpeg -encoders` for a list.
370
-
371
- Will use PCM audio with input stream bit depth by default.
372
-
373
- - `-b:a AUDIO_BITRATE, --audio-bitrate AUDIO_BITRATE`: Audio bitrate in bits/s, or with K suffix.
374
-
375
- If not specified, will use codec default.
376
-
377
- - `-ar SAMPLE_RATE, --sample-rate SAMPLE_RATE`: Audio sample rate to use for output files in Hz.
378
-
379
- Will use input sample rate by default, except for EBU normalization, which will change the input sample rate to 192 kHz.
380
-
381
- - `-ac`, `--audio-channels`: Set the number of audio channels. If not specified, the input channel layout will be used. This is equivalent to `-ac` in ffmpeg.
382
-
383
- - `-koa, --keep-original-audio`: Copy original, non-normalized audio streams to output file
384
-
385
- - `-prf PRE_FILTER, --pre-filter PRE_FILTER`: Add an audio filter chain before applying normalization.
386
-
387
- Multiple filters can be specified by comma-separating them.
388
-
389
- - `-pof POST_FILTER, --post-filter POST_FILTER`: Add an audio filter chain after applying normalization.
390
-
391
- Multiple filters can be specified by comma-separating them.
392
-
393
- For EBU, the filter will be applied during the second pass.
394
-
395
- ### Other Encoding Options
396
-
397
- - `-vn, --video-disable`: Do not write video streams to output
398
-
399
- - `-c:v VIDEO_CODEC, --video-codec VIDEO_CODEC`: Video codec to use for output files (default: 'copy').
400
-
401
- See `ffmpeg -encoders` for a list.
402
-
403
- Will attempt to copy video codec by default.
404
-
405
- - `-sn, --subtitle-disable`: Do not write subtitle streams to output
406
-
407
- - `-mn, --metadata-disable`: Do not write metadata to output
408
-
409
- - `-cn, --chapters-disable`: Do not write chapters to output
410
-
411
-
412
- ### Input/Output Format
413
-
414
- - `-ei EXTRA_INPUT_OPTIONS, --extra-input-options EXTRA_INPUT_OPTIONS`: Extra input options list.
415
-
416
- A list of extra ffmpeg command line arguments valid for the input, applied before ffmpeg's `-i`.
417
-
418
- You can either use a JSON-formatted list (i.e., a list of comma-separated, quoted elements within square brackets), or a simple string of space-separated arguments.
419
-
420
- If JSON is used, you need to wrap the whole argument in quotes to prevent shell expansion and to preserve literal quotes inside the string. If a simple string is used, you need to specify the argument with `-e=`.
421
-
422
- Examples: `-ei '[ "-f", "mpegts", "-r", "24" ]'` or `-ei="-f mpegts -r 24"`
423
-
424
- - `-e EXTRA_OUTPUT_OPTIONS, --extra-output-options EXTRA_OUTPUT_OPTIONS`: Extra output options list.
425
-
426
- A list of extra ffmpeg command line arguments valid for the output.
427
-
428
- You can either use a JSON-formatted list (i.e., a list of comma-separated, quoted elements within square brackets), or a simple string of space-separated arguments.
429
-
430
- If JSON is used, you need to wrap the whole argument in quotes to prevent shell expansion and to preserve literal quotes inside the string. If a simple string is used, you need to specify the argument with `-e=`.
431
-
432
- Examples: `-e '[ "-vbr", "3", "-preset:v", "ultrafast" ]'` or `-e="-vbr 3 -preset:v ultrafast"`
433
-
434
- - `-ofmt OUTPUT_FORMAT, --output-format OUTPUT_FORMAT`: Media format to use for output file(s).
435
-
436
- See `ffmpeg -formats` for a list.
437
-
438
- If not specified, the format will be inferred by ffmpeg from the output file name. If the output file name is not explicitly specified, the extension will govern the format (see '--extension' option).
439
-
440
- - `-ext EXTENSION, --extension EXTENSION`: Output file extension to use for output files that were not explicitly specified. (Default: `mkv`)
441
-
442
- ### Environment Variables
443
-
444
- The program additionally respects environment variables:
445
-
446
- - `TMP` / `TEMP` / `TMPDIR`
447
-
448
- Sets the path to the temporary directory in which files are
449
- stored before being moved to the final output directory.
450
- Note: You need to use full paths.
451
-
452
- - `FFMPEG_PATH`
453
-
454
- Sets the full path to an `ffmpeg` executable other than
455
- the system default or you can provide a file name available on $PATH
456
-
457
- ## API
458
-
459
- This program has a simple API that can be used to integrate it into other Python programs.
460
-
461
- For more information see the [API documentation](https://htmlpreview.github.io/?https://github.com/slhck/ffmpeg-normalize/blob/master/docs/ffmpeg_normalize.html).
462
-
463
- ## FAQ
464
-
465
- ### My output file is too large?
466
-
467
- This is because the default output codec is PCM, which is uncompressed. If you want to reduce the file size, you can specify an audio codec with `-c:a` (e.g., `-c:a aac` for ffmpeg's built-in AAC encoder), and optionally a bitrate with `-b:a`.
468
-
469
- For example:
470
-
471
- ```bash
472
- ffmpeg-normalize input.wav -o output.m4a -c:a aac -b:a 192k
473
- ```
474
-
475
- ### What options should I choose for the EBU R128 filter? What is linear and dynamic mode?
476
-
477
- EBU R128 is a method for normalizing audio loudness across different tracks or programs. It works by analyzing the audio content and adjusting it to meet specific loudness targets. The main components are:
478
-
479
- * Integrated Loudness (I): The overall loudness of the entire audio.
480
- * Loudness Range (LRA): The variation in loudness over time.
481
- * True Peak (TP): The maximum level of the audio signal.
482
-
483
- The normalization process involves measuring these values (input) and then applying gain adjustments to meet target levels (output), typically -23 LUFS for integrated loudness. You can also specify a target loudness range (LRA) and true peak level (TP).
484
-
485
- **Linear mode** applies a constant gain adjustment across the entire audio file. This is generally preferred because:
486
-
487
- * It preserves the original dynamic range of the audio.
488
- * It maintains the relative loudness between different parts of the audio.
489
- * It avoids potential artifacts or pumping effects that can occur with dynamic processing.
490
-
491
- **Dynamic mode**, on the other hand, can change the volume dynamically throughout the file. While this can achieve more consistent loudness, it may alter the original artistic intent and potentially introduce audible artifacts (possibly due to some bugs in the ffmpeg filter).
492
-
493
- For most cases, linear mode is recommended. Dynamic mode should only be used when linear mode is not suitable or when a specific effect is desired. In some cases, `loudnorm` will still fall back to dynamic mode, and a warning will be printed to the console. Here's when this can happen:
494
-
495
- * When the input loudness range (LRA) is larger than the target loudness range: If the input file has a loudness range that exceeds the specified loudness range target, the loudnorm filter will automatically switch to dynamic mode. This is because linear normalization alone cannot reduce the loudness range without dynamic processing (limiting). The `--keep-loudness-range-target` option can be used to keep the input loudness range target above the specified target.
496
-
497
- * When the required gain adjustment to meet the integrated loudness target would result in the true peak exceeding the specified true peak limit. This is because linear processing alone cannot reduce peaks without affecting the entire signal. For example, if a file needs to be amplified by 6 dB to reach the target integrated loudness, but doing so would push the true peak above the specified limit, the filter might switch to dynamic mode to handle this situation. If your content allows for it, you can increase the true peak target to give more headroom for linear processing. If you're consistently running into true peak issues, you might also consider lowering your target integrated loudness level.
498
-
499
- At this time, the `loudnorm` filter in ffmpeg does not provide a way to force linear mode when the input loudness range exceeds the target or when the true peak would be exceeded. There are some options to mitigate this:
500
-
501
- - The `--keep-lra-above-loudness-range-target` option can be used to keep the input loudness range above the specified target, but it will not force linear mode in all cases.
502
- - Similarly, the `--keep-loudness-range-target` option can be used to keep the input loudness range target.
503
- - The `--lower-only` option can be used to skip the normalization pass completely if the measured loudness is lower than the target loudness.
504
-
505
- ### The program doesn't work because the "loudnorm" filter can't be found
506
-
507
- Make sure you run a recent ffmpeg version and that `loudnorm` is part of the output when you run `ffmpeg -filters`. Many distributions package outdated ffmpeg versions, or (even worse), Libav's `ffmpeg` disguising as a real `ffmpeg` from the FFmpeg project.
508
-
509
- Some ffmpeg builds also do not have the `loudnorm` filter enabled.
510
-
511
- You can always download a static build from [their website](http://ffmpeg.org/download.html) and use that.
512
-
513
- If you have to use an outdated ffmpeg version, you can only use `rms` or `peak` as normalization types, but I can't promise that the program will work correctly.
514
-
515
- ### Should I use this to normalize my music collection?
516
-
517
- Generally, no.
518
-
519
- When you run `ffmpeg-normalize` and re-encode files with MP3 or AAC, you will inevitably introduce [generation loss](https://en.wikipedia.org/wiki/Generation_loss). Therefore, I do not recommend running this on your precious music collection, unless you have a backup of the originals or accept potential quality reduction. If you just want to normalize the subjective volume of the files without changing the actual content, consider using [MP3Gain](http://mp3gain.sourceforge.net/) and [aacgain](http://aacgain.altosdesign.com/).
520
-
521
- ### Why are my output files MKV?
522
-
523
- I chose MKV as a default output container since it handles almost every possible combination of audio, video, and subtitle codecs. If you know which audio/video codec you want, and which container is supported, use the output options to specify the encoder and output file name manually.
524
-
525
- ### I get a "Could not write header for output file" error
526
-
527
- See the [next section](#the-conversion-does-not-work-and-i-get-a-cryptic-ffmpeg-error).
528
-
529
- ### The conversion does not work and I get a cryptic ffmpeg error!
530
-
531
- Maybe ffmpeg says something like:
532
-
533
- > Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
534
-
535
- Or the program says:
536
-
537
- > … Please choose a suitable audio codec with the `-c:a` option.
538
-
539
- One possible reason is that the input file contains some streams that cannot be mapped to the output file, or that you are using a codec that does not work for the output file. Examples:
540
-
541
- - You are trying to normalize a movie file, writing to a `.wav` or `.mp3` file. WAV/MP3 files only support audio, not video. Disable video and subtitles with `-vn` and `-sn`, or choose a container that supports video (e.g. `.mkv`).
542
-
543
- - You are trying to normalize a file, writing to an `.mp4` container. This program defaults to PCM audio, but MP4 does not support PCM audio. Make sure that your audio codec is set to something MP4 containers support (e.g. `-c:a aac`).
544
-
545
- The default output container is `.mkv` as it will support most input stream types. If you want a different output container, [make sure that it supports](https://en.wikipedia.org/wiki/Comparison_of_container_file_formats) your input file's video, audio, and subtitle streams (if any).
546
-
547
- Also, if there is some other broken metadata, you can try to disable copying over of metadata with `-mn`.
548
-
549
- Finally, make sure you use a recent version of ffmpeg. The [static builds](https://ffmpeg.org/download.html) are usually the best option.
550
-
551
- ### What are the different normalization algorithms?
552
-
553
- - **EBU R128** is an EBU standard that is commonly used in the broadcasting world. The normalization is performed using a psychoacoustic model that targets a subjective loudness level measured in LUFS (Loudness Unit Full Scale). R128 is subjectively more accurate than any peak or RMS-based normalization. More info on R128 can be found in the [official document](https://tech.ebu.ch/docs/r/r128.pdf) and [the `loudnorm` filter description](http://k.ylo.ph/2016/04/04/loudnorm.html) by its original author.
554
-
555
- - **Peak Normalization** analyzes the peak signal level in dBFS and increases the volume of the input signal such that the maximum in the output is 0 dB (or any other chosen threshold). Since spikes in the signal can cause high volume peaks, peak normalization might still result in files that are subjectively quieter than other, non-peak-normalized files.
556
-
557
- - **RMS-based Normalization** analyzes the [RMS power](https://en.wikipedia.org/wiki/Root_mean_square#Average_power) of the signal and changes the volume such that a new RMS target is reached. Otherwise it works similar to peak normalization.
558
-
559
- ### Couldn't I just run `loudnorm` with ffmpeg?
560
-
561
- You absolutely can. However, you can get better accuracy and linear normalization with two passes of the filter. Since ffmpeg does not allow you to automatically run these two passes, you have to do it yourself and parse the output values from the first run.
562
-
563
- If ffmpeg-normalize is too over-engineered for you, you could also use an approach such as featured [in this Ruby script](https://gist.github.com/kylophone/84ba07f6205895e65c9634a956bf6d54) that performs the two `loudnorm` passes.
564
-
565
- If you want dynamic normalization (the loudnorm default), simply use ffmpeg with one pass, e.g.:
566
-
567
- ```bash
568
- ffmpeg -i input.mp3 -af loudnorm -c:a aac -b:a 192k output.m4a
569
- ```
570
-
571
- ### What about speech?
572
-
573
- You should check out the `speechnorm` filter that is part of ffmpeg. It is a designed to be used in one pass, so you don't need this script at all.
574
-
575
- See [the documentation](https://ffmpeg.org/ffmpeg-all.html#speechnorm) for more information.
576
-
577
- ### After updating, this program does not work as expected anymore!
578
-
579
- You are probably using a 0.x version of this program. There are significant changes to the command line arguments and inner workings of this program, so please adapt your scripts to the new one. Those changes were necessary to address a few issues that kept piling up; leaving the program as-is would have made it hard to extend it. You can continue using the old version (find it under *Releases* on GitHub or request the specific version from PyPi), but it will not be supported anymore.
580
-
581
- ### Can I buy you a beer / coffee / random drink?
582
-
583
- If you found this program useful and feel like giving back, feel free to send a donation [via PayPal](https://paypal.me/WernerRobitza).
584
-
585
- ## Related Tools and Articles
586
-
587
- - [Create an AppleScript application to drop or open a folder of files in ffmpeg-normalize](https://prehensileblog.wordpress.com/2022/04/15/create-an-applescript-application-to-drop-or-open-a-folder-of-files-in-ffmpeg-normalize/)
588
-
589
- *(Have a link? Please propose an edit to this section via a pull request!)*
590
-
591
- ## Contributors
63
+ The only reason this project exists in its current form is because [@benjaoming](https://github.com/slhck/ffmpeg-normalize/issues?q=is%3Apr+author%3Abenjaoming)'s initial PRs. Thanks for everyone's support!
592
64
 
593
65
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
594
66
  <!-- prettier-ignore-start -->
@@ -638,33 +110,33 @@ If you found this program useful and feel like giving back, feel free to send a
638
110
 
639
111
  <!-- ALL-CONTRIBUTORS-LIST:END -->
640
112
 
641
- ## License
642
113
 
643
- The MIT License (MIT)
114
+ # Changelog
644
115
 
645
- Copyright (c) 2015-2022 Werner Robitza
646
116
 
647
- Permission is hereby granted, free of charge, to any person obtaining a
648
- copy of this software and associated documentation files (the
649
- "Software"), to deal in the Software without restriction, including
650
- without limitation the rights to use, copy, modify, merge, publish,
651
- distribute, sublicense, and/or sell copies of the Software, and to
652
- permit persons to whom the Software is furnished to do so, subject to
653
- the following conditions:
117
+ ## v1.32.0 (2025-05-07)
654
118
 
655
- The above copyright notice and this permission notice shall be included
656
- in all copies or substantial portions of the Software.
119
+ * Docs: update contributing guide.
657
120
 
658
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
659
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
660
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
661
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
662
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
663
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
664
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
121
+ * Docs: convert options to headlines.
665
122
 
123
+ * Docs: update ffmpeg guide.
666
124
 
667
- # Changelog
125
+ * Fix: do not write replaygain tags if dry run is used.
126
+
127
+ * Fix: flake8 no longer used.
128
+
129
+ * Fix docs links.
130
+
131
+ * Add mkdocs documentation.
132
+
133
+ * Update python in dockerfile.
134
+
135
+ * Remove years from copyright.
136
+
137
+ * Dev stuff.
138
+
139
+ * Add replaygain support.
668
140
 
669
141
 
670
142
  ## v1.31.3 (2025-04-14)