1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
|
%global _empty_manifest_terminate_build 0
Name: python-ffmpeg-normalize
Version: 1.26.6
Release: 1
Summary: Normalize audio via ffmpeg
License: MIT
URL: https://github.com/slhck/ffmpeg-normalize
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/0e/43/f0e9c69d0ee5863dd7ba5f6db1bd73b2462b1e8b74a42afff986a46c172c/ffmpeg-normalize-1.26.6.tar.gz
BuildArch: noarch
Requires: python3-tqdm
Requires: python3-colorama
Requires: python3-ffmpeg-progress-yield
Requires: python3-colorlog
%description
## Requirements
You need Python 3.8 or higher.
### ffmpeg
- ffmpeg 5.x is required
- Download a [static build](https://ffmpeg.org/download.html) for your system
- Place the `ffmpeg` executable in your `$PATH`, or specify the path to the binary with the `FFMPEG_PATH` environment variable in `ffmpeg-normalize`
For instance, under Linux:
```bash
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
mkdir -p ffmpeg
tar -xf ffmpeg-release-amd64-static.tar.xz -C ffmpeg --strip-components=1
sudo cp ffmpeg/ffmpeg /usr/local/bin
sudo cp ffmpeg/ffprobe /usr/local/bin
sudo chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
```
For Windows, follow [this guide](https://www.wikihow.com/Install-FFmpeg-on-Windows).
For macOS and Linux, you can also use [Homebrew](https://brew.sh):
```bash
brew install ffmpeg
```
Note that using distribution packages (e.g., `apt install ffmpeg`) is not recommended, as these are often outdated.
## Installation
For Python 3 and pip:
```bash
pip3 install ffmpeg-normalize
```
Or download this repository, then run `pip3 install .`.
## Usage
```
ffmpeg-normalize [-h]
[-o OUTPUT [OUTPUT ...]] [-of OUTPUT_FOLDER]
[-f] [-d] [-v] [-q] [-n] [-pr]
[--version]
[-nt {ebu,rms,peak}]
[-t TARGET_LEVEL] [-p] [-lrt LOUDNESS_RANGE_TARGET] [-tp TRUE_PEAK] [--offset OFFSET] [--dual-mono] [--dynamic]
[-c:a AUDIO_CODEC] [-b:a AUDIO_BITRATE] [-ar SAMPLE_RATE] [-koa]
[-prf PRE_FILTER] [-pof POST_FILTER]
[-vn] [-c:v VIDEO_CODEC]
[-sn] [-mn] [-cn]
[-ei EXTRA_INPUT_OPTIONS] [-e EXTRA_OUTPUT_OPTIONS]
[-ofmt OUTPUT_FORMAT] [-ext EXTENSION]
input [input ...]
```
For more information, run `ffmpeg-normalize -h`, or read on.
## Description
Please read this section for a high level introduction.
**What does the program do?**
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.
**How do I specify the input?**
Just give the program one or more input files as arguments. It works with most media files.
**How do I specify the output?**
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.
Example:
```
ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav
```
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`.
Using the `-ext` option, you can supply a different output extension common to all output files, e.g. `-ext m4a`.
**What will get normalized?**
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.
**How will the normalization be done?**
The normalization will be performed with the [`loudnorm` filter](http://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.
**What codec is chosen?**
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.
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).
## Examples
[Read the examples on the the wiki.](https://github.com/slhck/ffmpeg-normalize/wiki/examples)
## Detailed Options
### File Input/Output
- `input`: Input media file(s)
- `-o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]`: Output file names.
Will be applied per input file.
If no output file name is specified for an input file, the output files
will be written to the default output folder with the name `<input>.<ext>`, where `<ext>` is the output extension (see `-ext` option).
Example: `ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav`
- `-of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER`: Output folder (default: `normalized`)
This folder will be used for input files that have no explicit output name specified.
### General
- `-f, --force`: Force overwrite existing files
- `-d, --debug`: Print debugging output
- `-v, --verbose`: Print verbose output
- `-q, --quiet`: Only print errors
- `-n, --dry-run`: Do not run normalization, only print what would be done
- `-pr`, `--progress`: Show progress bar for files and streams
- `--version`: Print version and exit
### Normalization
- `-nt {ebu,rms,peak}, --normalization-type {ebu,rms,peak}`: Normalization type (default: `ebu`).
EBU normalization performs two passes and normalizes according to EBU R128.
RMS-based normalization brings the input file to the specified RMS level.
Peak normalization brings the signal to the specified peak level.
- `-t TARGET_LEVEL, --target-level TARGET_LEVEL`: Normalization target level in dB/LUFS (default: -23).
For EBU normalization, it corresponds to Integrated Loudness Target in LUFS. The range is -70.0 - -5.0.
Otherwise, the range is -99 to 0.
- `-p, --print-stats`: Print first pass loudness statistics formatted as JSON to stdout.
### EBU R128 Normalization
- `-lrt LOUDNESS_RANGE_TARGET, --loudness-range-target LOUDNESS_RANGE_TARGET`: EBU Loudness Range Target in LUFS (default: 7.0).
Range is 1.0 - 50.0.
- `--keep-loudness-range-target`: Keep the input loudness range target to allow for linear normalization.
- `-tp TRUE_PEAK, --true-peak TRUE_PEAK`: EBU Maximum True Peak in dBTP (default: -2.0).
Range is -9.0 - +0.0.
- `--offset OFFSET`: EBU Offset Gain (default: 0.0).
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.
Range is -99.0 - +99.0.
- `--dual-mono`: Treat mono input files as "dual-mono".
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.
- `--dynamic`: Force dynamic normalization mode.
Instead of applying linear EBU R128 normalization, choose a dynamic normalization. This is not usually recommended.
Dynamic mode will automatically change the sample rate to 192 kHz. Use -ar/--sample-rate to specify a different output sample rate.
### Audio Encoding
- `-c:a AUDIO_CODEC, --audio-codec AUDIO_CODEC`: Audio codec to use for output files.
See `ffmpeg -encoders` for a list.
Will use PCM audio with input stream bit depth by default.
- `-b:a AUDIO_BITRATE, --audio-bitrate AUDIO_BITRATE`: Audio bitrate in bits/s, or with K suffix.
If not specified, will use codec default.
- `-ar SAMPLE_RATE, --sample-rate SAMPLE_RATE`: Audio sample rate to use for output files in Hz.
Will use input sample rate by default, except for EBU normalization, which will change the input sample rate to 192 kHz.
- `-koa, --keep-original-audio`: Copy original, non-normalized audio streams to output file
- `-prf PRE_FILTER, --pre-filter PRE_FILTER`: Add an audio filter chain before applying normalization.
Multiple filters can be specified by comma-separating them.
- `-pof POST_FILTER, --post-filter POST_FILTER`: Add an audio filter chain after applying normalization.
Multiple filters can be specified by comma-separating them.
For EBU, the filter will be applied during the second pass.
### Other Encoding Options
- `-vn, --video-disable`: Do not write video streams to output
- `-c:v VIDEO_CODEC, --video-codec VIDEO_CODEC`: Video codec to use for output files (default: 'copy').
See `ffmpeg -encoders` for a list.
Will attempt to copy video codec by default.
- `-sn, --subtitle-disable`: Do not write subtitle streams to output
- `-mn, --metadata-disable`: Do not write metadata to output
- `-cn, --chapters-disable`: Do not write chapters to output
### Input/Output Format
- `-ei EXTRA_INPUT_OPTIONS, --extra-input-options EXTRA_INPUT_OPTIONS`: Extra input options list.
A list of extra ffmpeg command line arguments valid for the input, applied before ffmpeg's `-i`.
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.
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=`.
Examples: `-ei '[ "-f", "mpegts", "-r", "24" ]'` or `-ei="-f mpegts -r 24"`
- `-e EXTRA_OUTPUT_OPTIONS, --extra-output-options EXTRA_OUTPUT_OPTIONS`: Extra output options list.
A list of extra ffmpeg command line arguments valid for the output.
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.
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=`.
Examples: `-e '[ "-vbr", "3", "-preset:v", "ultrafast" ]'` or `-e="-vbr 3 -preset:v ultrafast"`
- `-ofmt OUTPUT_FORMAT, --output-format OUTPUT_FORMAT`: Media format to use for output file(s).
See `ffmpeg -formats` for a list.
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).
- `-ext EXTENSION, --extension EXTENSION`: Output file extension to use for output files that were not explicitly specified. (Default: `mkv`)
### Environment Variables
The program additionally respects environment variables:
- `TMP` / `TEMP` / `TMPDIR`
Sets the path to the temporary directory in which files are
stored before being moved to the final output directory.
Note: You need to use full paths.
- `FFMPEG_PATH`
Sets the full path to an `ffmpeg` executable other than
the system default or you can provide a file name available on $PATH
## API
This program has a simple API that can be used to integrate it into other Python programs.
For more information see the [API documentation](https://htmlpreview.github.io/?https://github.com/slhck/ffmpeg-normalize/blob/master/docs/ffmpeg_normalize.html).
## FAQ
### The program doesn't work because the "loudnorm" filter can't be found
Make sure you run ffmpeg v3.1 or higher and that `loudnorm` is part of the output when you run `ffmpeg -filters`. Many distributions package outdated ffmpeg 2.x versions, or (even worse), Libav's `ffmpeg` disguising as a real `ffmpeg` from the FFmpeg project.
Some ffmpeg builds also do not have the `loudnorm` filter enabled.
You can always download a static build from [their website](http://ffmpeg.org/download.html) and use that.
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.
### Should I use this to normalize my music collection?
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/).
### Why are my output files MKV?
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.
### "Could not write header for output file" error
See the [next section](#the-conversion-does-not-work-and-i-get-a-cryptic-ffmpeg-error).
### The conversion does not work and I get a cryptic ffmpeg error!
Maybe ffmpeg says something like:
> Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Or the program says:
> β¦ Please choose a suitable audio codec with the `-c:a` option.
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:
- 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`).
- 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`).
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).
Also, if there is some other broken metadata, you can try to disable copying over of metadata with `-mn`.
Finally, make sure you use a recent version of ffmpeg. The [static builds](https://ffmpeg.org/download.html) are usually the best option.
### What are the different normalization algorithms?
- **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.
- **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.
- **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.
### Couldn't I just run `loudnorm` with ffmpeg?
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.
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.
If you want dynamic normalization (the loudnorm default), simply use ffmpeg with one pass, e.g.:
```bash
ffmpeg -i input.mp3 -af loudnorm -c:a aac -b:a 192k output.m4a
```
### What about speech?
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.
See [the documentation](https://ffmpeg.org/ffmpeg-all.html#speechnorm) for more information.
### After updating, this program does not work as expected anymore!
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.
### Can I buy you a beer / coffee / random drink?
If you found this program useful and feel like giving back, feel free to send a donation [via PayPal](https://paypal.me/WernerRobitza).
## Related Tools and Articles
- [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/)
*(Have a link? Please propose an edit to this section via a pull request!)*
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://overtag.dk/"><img src="https://avatars.githubusercontent.com/u/374612?v=4?s=100" width="100px;" alt="Benjamin Balder Bach"/><br /><sub><b>Benjamin Balder Bach</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=benjaoming" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://chaos.social/@eleni"><img src="https://avatars.githubusercontent.com/u/511547?v=4?s=100" width="100px;" alt="Eleni Lixourioti"/><br /><sub><b>Eleni Lixourioti</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Geekfish" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/thenewguy"><img src="https://avatars.githubusercontent.com/u/77731?v=4?s=100" width="100px;" alt="thenewguy"/><br /><sub><b>thenewguy</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=thenewguy" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/aviolo"><img src="https://avatars.githubusercontent.com/u/560229?v=4?s=100" width="100px;" alt="Anthony Violo"/><br /><sub><b>Anthony Violo</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=aviolo" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://jacobs.af/"><img src="https://avatars.githubusercontent.com/u/952830?v=4?s=100" width="100px;" alt="Eric Jacobs"/><br /><sub><b>Eric Jacobs</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=jetpks" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kostalski"><img src="https://avatars.githubusercontent.com/u/34033008?v=4?s=100" width="100px;" alt="kostalski"/><br /><sub><b>kostalski</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=kostalski" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://justinppearson.com/"><img src="https://avatars.githubusercontent.com/u/8844823?v=4?s=100" width="100px;" alt="Justin Pearson"/><br /><sub><b>Justin Pearson</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=justinpearson" title="Code">π»</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Nottt"><img src="https://avatars.githubusercontent.com/u/13532436?v=4?s=100" width="100px;" alt="ad90xa0-aa"/><br /><sub><b>ad90xa0-aa</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Nottt" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Mathijsz"><img src="https://avatars.githubusercontent.com/u/1891187?v=4?s=100" width="100px;" alt="Mathijs"/><br /><sub><b>Mathijs</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Mathijsz" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mpuels"><img src="https://avatars.githubusercontent.com/u/2924816?v=4?s=100" width="100px;" alt="Marc PΓΌls"/><br /><sub><b>Marc PΓΌls</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=mpuels" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.mvbattista.com/"><img src="https://avatars.githubusercontent.com/u/158287?v=4?s=100" width="100px;" alt="Michael V. Battista"/><br /><sub><b>Michael V. Battista</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=mvbattista" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://auto-editor.com"><img src="https://avatars.githubusercontent.com/u/57511737?v=4?s=100" width="100px;" alt="WyattBlue"/><br /><sub><b>WyattBlue</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=WyattBlue" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/g3n35i5"><img src="https://avatars.githubusercontent.com/u/17593457?v=4?s=100" width="100px;" alt="Jan-Frederik Schmidt"/><br /><sub><b>Jan-Frederik Schmidt</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=g3n35i5" title="Code">π»</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="7">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## License
The MIT License (MIT)
Copyright (c) 2015-2022 Werner Robitza
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Changelog
## v1.26.6 (2023-03-16)
* Production status stable.
* Make install_requires more abstract.
## v1.26.5 (2023-03-15)
* Add "-hide_banner" remove "-nostdin" (#222)
The `-nostdin` option is unnessary because of the `-y` option.
Adding `-hide_banner` makes DEBUG statements shorter.
* Homebrew works on linux too.
* Explain ffmpeg installation steps.
## v1.26.4 (2023-02-08)
* Re-add requirements.txt to (maybe) fix conda-forge builds.
## v1.26.3 (2023-02-08)
* Fix requirements (#218)
* Improve types.
* Docs: add @g3n35i5 as a contributor.
## v1.26.2 (2023-02-06)
* Add ignore-revs file.
* Formatting and import sorting.
* Refactor: Improved logging behavior (#216)
* Add "apt update" (#215)
* Remove stalebot.
* Update README.
* Move to_ms and make CommandRunner more ergonomic (#212)
* Upgrade workflow, get ffmpeg from apt (#213)
* Turn FFmpegNormalizeError into a normal Exception (#211)
* Remove manifest.in (#210)
* Simplify logging (#209)
* Use pep585 type hints (#207)
* Don't use tempfile's private module function (#206)
* Fix smaller type errors.
* Reduce mypy errors 12 -> 4 (#204)
* Make input validation more efficient.
Make input validation more efficient
Re-separate formats and exts
## v1.26.1 (2022-12-18)
* Bump requirements.
* Add py.typed support.
* General refactoring + type hints (#202)
* Re-write to f-strings when possible (#201)
* Remove unnecessary utf-8 declarations (#200)
"-*- coding: utf-8 -*-" is a Python 2 construct and can be safely
removed. Other utf-8 declarations are also unnecessary.
## v1.26.0 (2022-12-14)
* Add .editorconfig.
* Link to API docs.
* Add docs.
* Add type hints, document everything, refactor some code.
* Add more audio formats (#199)
* Add python 3.11 to CI.
* Docs: add WyattBlue as a contributor for code (#198)
* docs: update README.md
* docs: update .all-contributorsrc
* Upgrade to Python 3.8 syntax (#197)
* Fix python version in github tests.
* Bump requirements to latest versions.
* Add python 3.11 to list of languages.
* Bump required python version to 3.8.
* Various minor code cleanups and type hints.
* Harmonize logger code.
* Update python version in tests.
* Docs: add @mvbattista as a contributor.
* Docs: add @mpuels as a contributor.
* Docs: add @Mathijsz as a contributor.
* Docs: add @Nottt as a contributor.
* Docs: add @justinpearson as a contributor.
* Docs: add @kostalski as a contributor.
* Docs: add @jetpks as a contributor.
* Docs: add @aviolo as a contributor.
* Docs: add @thenewguy as a contributor.
* Docs: add @Geekfish as a contributor.
* Docs: add @benjaoming as a contributor.
* Reference speechnorm.
## v1.25.3 (2022-11-09)
* Update README.
* Update list of pcm-incompatible extensions.
## v1.25.2 (2022-09-14)
* Constrain parsed ranges to avoid out of bounds, fixes #189.
* Fix readme for extra-input-options.
* Warn about dynamic mode only if not already set, fixes #187.
## v1.25.1 (2022-08-21)
* Add warning in case user specifies both --lrt and --keep-loudness-range-target.
## v1.25.0 (2022-08-20)
* Add option to keep loudness range target, fixes #181.
* Only show warning about disabling video if not yet disabled, addresses #184.
## v1.24.1 (2022-08-20)
* Code formatting.
* Extend warning for audio-only format to opus, fixes #184.
## v1.24.0 (2022-08-02)
* Update python requirements.
* Prevent race condition in output dir creation.
## v1.23.1 (2022-07-12)
* Increase possible loudness range target to 50.
## v1.23.0 (2022-05-01)
* Add way to force dynamic mode, clarify usage, fixes #176.
## v1.22.10 (2022-04-25)
* Add warning for cover art, addresses #174 and #175.
* Update README.
## v1.22.9 (2022-04-17)
* Improve issue templates.
* Do not print ffmpeg progress in debug logs.
* Remove unused import.
* Replace which() function with shlex version.
* Add python 3.10 in setup.py.
* Clarify minimum ffmpeg version.
## v1.22.8 (2022-03-07)
* Properly detect -inf dB input.
## v1.22.7 (2022-02-25)
* Debug command output for ffmpeg commands.
* Remove unneeded warning message.
## v1.22.6 (2022-02-20)
* Use astats instead of volumedetect filter, fixes #163.
Allows floating point calculation.
## v1.22.5 (2022-01-25)
* Print warning for bit depths > 16, addresses #163.
## v1.22.4 (2021-10-18)
* Re-raise error on ffmpeg command failure.
This prevents incorrectly telling the user that a normalized file was written when it wasn't.
## v1.22.3 (2021-08-31)
* Set tqdm lock for logging only when multiprocessing is available.
Multiprocessing is not available in all environments, for example
on AWS lambda python run time lacks /dev/shm, so trying to acquire
a multiprocessing Lock throws an OSError. The module could also be
missing in some cases (ex. Jython, although this library doesn't support
Jython anyway).
The solution to this is to only try to set the lock when multiprocessing
is available. The tqdm library solves this in the same manner.
For more details: https://github.com/slhck/ffmpeg-normalize/issues/156
* Add instructions on how to run tests.
## v1.22.2 (2021-08-14)
* Bump requirements, should fix #155.
* Move all examples to Wiki.
* Update badge link.
## v1.22.1 (2021-03-10)
* Add python_requires to setup.py.
## v1.22.0 (2021-03-09)
* Improve README.
* Add GitHub actions badge.
* Add GitHub actions tests.
* Properly convert EBU JSON values to float.
* Switch to f strings, remove Python 3.5 support.
* Format code with black.
* Fix flake8 errors.
* Factor out method.
* WIP: new tests.
* Log to stderr by default to enable JSON parsing.
* Remove release script.
## v1.21.2 (2021-03-06)
* Format setup.py.
* Switch progress to external lib.
* Remove support for older versions.
## v1.21.1 (2021-03-05)
* Adjusted handling of FFMPEG_PATH for binaries available via $PATH (#149)
* adjusted handling of FFMPEG_PATH for binaries available via $PATH
fixes #147
* adjusted use of %s to {} to match style
* documented the feature
* condensed error message as other lines are longer
## v1.21.0 (2021-02-27)
* Fix JSON output for multiple files.
* Update badge URL.
* Update README.md (#142)
* Update README.md
Added example of verifying levels
Fixes #141
* shorten example, add link to wiki page
* Error if no ffmpeg exec exists.
* Add stalebot.
## v1.20.2 (2020-11-06)
* Fixing stdin corruption caused by new subprocess (#138)
* Update issue template.
* Create FUNDING.yml.
* Fix usage, addresses #132.
## v1.20.1 (2020-07-22)
* Manually specify usage string, fixes #132.
* Fix local import for tests.
## v1.20.0 (2020-07-04)
* Add extra input options.
## v1.19.1 (2020-06-25)
* Add colorama to requirements, fixes #131.
* Fix warning that is printed with default options.
## v1.19.0 (2020-05-02)
* Fix issue with output folder, fixes #126.
* Fix typo in README's table of contents link to "File Input/Output". (#124)
* Clarify readme, fixes #122.
## v1.18.2 (2020-04-19)
* Add warning for automatic sample rate conversion, addresses #122.
* Ignore vscode folder.
* Fix printing of errors in conversion.
## v1.18.1 (2020-04-16)
* Fix unit tests.
* Improve handling of output file folder and errors.
* Clarify usage of output options, add warning.
* Improve documentation, fixes #120.
* Do not include bump messages in changelog.
## v1.18.0 (2020-04-13)
* Use measured offset in second pass, fixes #119.
* Update release instructions.
* Remove author names from changelog.
## v1.17.0 (2020-04-10)
* Update release script and changelog template.
* Apply pre-filters in all first passes, fixes #118.
This allows properly reading the level for any kind of normalization, even if
filters affect the loudness in the first pass.
## v1.16.0 (2020-04-07)
* Add all commits to changelog.
* Remove python 2 support.
* Add quiet option, fixes #116.
- Add a new quiet option
- Promote some warnings to actual errors that need to be shown
- Add a very basic test case
## v1.15.8 (2020-03-15)
* Improve release script.
* Python 3.8.
## v1.15.7 (2020-03-14)
* Only print length warning for non-EBU type normalization.
## v1.15.6 (2019-12-04)
* Remove build and dist folder on release.
* Do not exit on error in batch processing.
Simply process the next file if one has errors, addresses #110.
## v1.15.5 (2019-11-19)
* Use minimal dependency for tqdm.
* Remove specific python version requirement.
## v1.15.4 (2019-11-19)
* Freeze tqdm version.
* Update python to 3.7.
* Improve release documentation.
## v1.15.3 (2019-10-15)
* Do not print stream warning when there is only one stream.
* Remove previous dist versions before release.
## v1.15.2 (2019-07-12)
* Warn when duration cannot be read, fixes #105.
* Update README.
minor improvements in the description
## v1.15.1 (2019-06-17)
* Add output to unit test failures.
* Fix input label for audio stream.
## v1.15.0 (2019-06-17)
* Add pre-and post-filter hooks, fixes #67.
This allows users to specify filters to be run before or after the actual
normalization call, using regular ffmpeg syntax.
Only applies to audio.
* Document audiostream class.
* Warn when file is too short, fixes #87.
* Update release method to twine.
## v1.14.1 (2019-06-14)
* Handle progress output from ffmpeg, fixes #10.
* Merge pull request #99 from Nottt/patch-1.
fix -cn description
* Fix -cn description.
* Add nicer headers for options in README.
## v1.14.0 (2019-04-24)
* Add version file in release script before committing.
* Add option to keep original audio, fixes #83.
* Add pypi badge.
* Allow release script to add changelog for future version; upload to pypi.
## v1.13.11 (2019-04-16)
* Add release script.
* Add small developer guide on releasing.
* Move HISTORY.md to CHANGELOG.md.
* Fix ffmpeg static build download location.
## v1.3.10 (2019-02-22)
* Bump version.
* Cap measured input loudness, fixes #92.
## v1.3.9 (2019-01-10)
* Bump version.
* Fix handling of errors with tqdm.
* Improve readme.
* Delete issue template.
* Bump version.
* Clarify extra argument options, move to main entry point.
* Update issue templates.
## v1.3.8 (2018-11-28)
* Bump version.
* Clarify extra argument options, move to main entry point.
## v1.3.7 (2018-10-28)
* Bump version.
* Copy metadata from individual streams, fixes #86.
* Add python version for pyenv.
## v1.3.6 (2018-07-09)
* Bump version.
* Update README, fixes #79 and addresses #80.
## v1.3.5 (2018-06-12)
* Bump version.
* Minor README updates.
* Fix documentation of TMPDIR parameter.
## v1.3.4 (2018-05-05)
* Bump version.
* New way to specify extra options.
## v1.3.3 (2018-05-05)
* Update README.
* Decode strings in extra options.
## v1.3.2 (2018-04-25)
* Bump version.
* Merge pull request #69 from UbiCastTeam/master.
Stderror decoding ignoring utf8 encoding errors
* Stderror decoding ignoring utf8 encoding errors.
## v1.3.1 (2018-04-24)
* Bump version.
* Do not require main module in setup.py, fixes #68.
## v1.3.0 (2018-04-15)
* Bump version.
* Remove dead code.
* Fix for python2 division.
* Update documentation.
* Progress bar.
* Remove imports from test file.
* Fix travis file.
* WIP: progress bar.
* Minor typo in option group.
* Add simple unit test for disabling chapters.
## v1.2.3 (2018-04-11)
* Fix unit test.
* Bump version.
* Add option to disable chapters, fixes #65, also fix issue with metadata.
## v1.2.2 (2018-04-10)
* Bump version.
* Set default loudness target to -23, fixes #48.
## v1.2.1 (2018-04-04)
* Bump version.
* Merge pull request #64 from UbiCastTeam/encoding-issue.
Stdout and stderror decoding ignoring utf8 encoding errors
* Stdout and stderror decoding ignoring utf8 encoding errors.
## v1.2.0 (2018-03-22)
* Bump version.
* Add errors for impossible format combinations, fixes #60.
* Fix ordering of output maps, fixes #63.
* Improve documentation.
## v1.1.0 (2018-03-06)
* Add option to print first pass statistics.
## v1.0.10 (2018-03-04)
* Bump version.
* Restrict parsing to valid JSON part only, fixes #61.
* Add an example for MP3 encoding.
* Update paypal link.
## v1.0.9 (2018-02-08)
* Bump version.
* Add normalized folder to gitignore.
* Do not print escape sequences on Windows.
* Do not check for file existence, fixes #57.
* Add github issue template.
## v1.0.8 (2018-02-01)
* Bump version.
* Do not check for ffmpeg upon module import.
## v1.0.7 (2018-02-01)
* Bump version.
* Rename function test.
* Fix issue with wrong adjustment parameters, fixes #54.
## v1.0.6 (2018-01-30)
* Allow setting FFMPEG_PATH and document TMP.
## v1.0.5 (2018-01-26)
* Handle edge case for short input clips.
## v1.0.4 (2018-01-26)
* Bump version.
* Do not try to remove nonexisting file in case of error in command.
## v1.0.3 (2018-01-26)
* Bump version.
* Always streamcopy when detecting streams to avoid initializing encoder.
* Fix handling of temporary file.
* Add build status.
* Travis tests.
## v1.0.2 (2018-01-25)
* Fix bug with target level for peak/RMS.
* Update documentation formatting.
* Update history.
## v1.0.1 (2018-01-24)
* Bump version.
* Set default target to -23.
## v1.0.0 (2018-01-23)
* Add version info and test case for dry run.
* New feature detection, add documentation, contributors guide etc.
* WIP: v1.0 rewrite.
## v0.7.3 (2017-10-09)
* Use shutil.move instead of os.rename.
## v0.7.2 (2017-09-17)
* Allow setting threshold to 0.
## v0.7.1 (2017-09-14)
* Bump version.
* Update HISTORY.md.
* Merge pull request #37 from Mathijsz/fix-which-path-expansion.
expand tilde and environment variables, fixes #36
* Expand tilde and environment variables, fixes #36.
* Update HISTORY.md.
* Update README w.r.t. loudnorm filter.
* Update README and indentation.
## v0.7.0 (2017-08-02)
* Bump version.
* Fix handling of extra options with spaces.
* Include test script.
* Logging and other improvements.
* Add test files.
* Autopep8 that thing.
* Logger improvements.
* Add example for overwriting.
## v0.6.0 (2017-07-31)
* Allow overwriting input file, fixes #22.
* Version bump.
* Better handle cmd arguments.
* Update README.md.
add another example
## v0.5.1 (2017-04-04)
* Fix for problem introduced in 304e8df.
## v0.5 (2017-04-02)
* Fix pypi topics.
* Bump version and README.
* Fix issue where output was wrong format.
* Add EBU R128 filter.
* Use Markdown instead of RST for README/HISTORY.
* Define file encode for python3, fixes #24.
* Fix history.
* Fix option -np.
* Clarify merge option.
* Minor documentation improvements.
- change README from CRLF to LF
- add "attenuated" in description
- extend LICENSE year
- add license to main README
## v0.4.1 (2017-02-13)
* Update for release.
* Merge pull request #21 from mpuels/patch-1.
Fix for #13
* Fix for #13.
* Mention Python 3.
mention that Python 3 may work, just didn't have time to test
* Fix README's code blocks.
## v0.4 (2017-01-24)
* Code cleanup, add option to set format and audio codec.
## v0.3 (2017-01-19)
* Add option for no prefix, fixes #20.
* Handle multiple spaces in path; fixes issue #18.
* Handle spaces in path, fixes #12.
* Update README.rst.
* Change default level back to -26.
* Typo in README example.
* Update documentation.
* Bump to v0.2.0.
* Support for multiple files and output directories.
* Support merging of audio with input file
* Set audio codec and additional options
* User-definable threshold
* Better error handling and logging
* Deprecates avconv
* Change default level back to -28.
* Merge pull request #15 from auricgoldfinger/master.
Add extended normalisation options
* Add extended normalisation options.
- add program option to write output in a separate directory in stead of
prefixing it
- add program option to merge the normalized audio in the original
(video) file rather than creating a separate WAV file
- change the maximum setting: will now normalize so that max
volume is set to 0, adjusted with the given level.
e.g. : -m -l -5 will increase the audio level to max = -5.0dB
- improve verbose logging: number of files are written to the
info log
- improve performance: check first whether the output file
exists before calculating the volume levels + not modifying
the file if the adjustment < 0.5dB (level is never exactly 0)
* Update README, fixes #11.
## v0.1.3 (2015-12-15)
* Check for Windows .exe, fixes #10.
* Check path and fix #9.
* Merge pull request #8 from benjaoming/master.
Add MANIFEST.in
* Bump version.
* Add manifest to include missing files in sdist.
* Merge pull request #6 from jetpks/master.
Fixed ffmpeg v2.6.3 compatibility and docopt config
* Updated to work with ffmpeg v2.6.3, and fixed broken docopt config.
ffmpeg update:
ffmpeg v2.6.3 puts mean_volume on stderr instead of stdout, causing
`output` in `ffmpeg_get_mean` to be completely empty, and no match for
mean_volume or max_volume to be found.
Fixed by adding `stderr=subprocess.PIPE` in both Popen calls in
`run_command`, and combining stdout and stderr on return. We already
exit with non-zero return, so combining stderr/stdout shouldn't cause
any poor side-effects.
docopt config:
- args['--level'] was not recognizing its default because there was
an errant comma between -l and --level, and it needed <level> after
the arguments.
- Fixed spacing for --max
- Removed quotes around 'normalized' so single quote characters don't
end up in the output file names.
* Removed Windows carraige returns from __main__.py.
* Merge pull request #5 from mvbattista/master.
Installation update to ffmpeg
* Installation update to ffmpeg.
* Update to ffmpeg.
* Update HISTORY.rst.
* Update to ffmpeg.
* Merge pull request #4 from benjaoming/rename.
Rename project
* Make at least one file mandatory.
* Rename project and remove pyc file.
* Merge pull request #2 from benjaoming/docopt-setuptools-avconv.
Docopt, Setuptools, avconv compatibility
* Use docopt.
* Use normalize-audio when using avconv because it doesn't have a way to measure volume.
* Functional setup.py, communicate with avconv/ffmpeg about overwriting.
* Also detect avconv.
* Use a main function instead.
* Add a history for the project.
* Move to more unique module name.
* Update README.rst.
* Change the README to rst (PyPi)
* Delete .gitignore.
* Update README.md.
* Various improvements, fixes #1.
* License.
* Livense.
* Update README.md.
* Merge branch 'master' of https://github.com/slhck/audio-normalize.
* Initial commit.
* Initial commit.
%package -n python3-ffmpeg-normalize
Summary: Normalize audio via ffmpeg
Provides: python-ffmpeg-normalize
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-ffmpeg-normalize
## Requirements
You need Python 3.8 or higher.
### ffmpeg
- ffmpeg 5.x is required
- Download a [static build](https://ffmpeg.org/download.html) for your system
- Place the `ffmpeg` executable in your `$PATH`, or specify the path to the binary with the `FFMPEG_PATH` environment variable in `ffmpeg-normalize`
For instance, under Linux:
```bash
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
mkdir -p ffmpeg
tar -xf ffmpeg-release-amd64-static.tar.xz -C ffmpeg --strip-components=1
sudo cp ffmpeg/ffmpeg /usr/local/bin
sudo cp ffmpeg/ffprobe /usr/local/bin
sudo chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
```
For Windows, follow [this guide](https://www.wikihow.com/Install-FFmpeg-on-Windows).
For macOS and Linux, you can also use [Homebrew](https://brew.sh):
```bash
brew install ffmpeg
```
Note that using distribution packages (e.g., `apt install ffmpeg`) is not recommended, as these are often outdated.
## Installation
For Python 3 and pip:
```bash
pip3 install ffmpeg-normalize
```
Or download this repository, then run `pip3 install .`.
## Usage
```
ffmpeg-normalize [-h]
[-o OUTPUT [OUTPUT ...]] [-of OUTPUT_FOLDER]
[-f] [-d] [-v] [-q] [-n] [-pr]
[--version]
[-nt {ebu,rms,peak}]
[-t TARGET_LEVEL] [-p] [-lrt LOUDNESS_RANGE_TARGET] [-tp TRUE_PEAK] [--offset OFFSET] [--dual-mono] [--dynamic]
[-c:a AUDIO_CODEC] [-b:a AUDIO_BITRATE] [-ar SAMPLE_RATE] [-koa]
[-prf PRE_FILTER] [-pof POST_FILTER]
[-vn] [-c:v VIDEO_CODEC]
[-sn] [-mn] [-cn]
[-ei EXTRA_INPUT_OPTIONS] [-e EXTRA_OUTPUT_OPTIONS]
[-ofmt OUTPUT_FORMAT] [-ext EXTENSION]
input [input ...]
```
For more information, run `ffmpeg-normalize -h`, or read on.
## Description
Please read this section for a high level introduction.
**What does the program do?**
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.
**How do I specify the input?**
Just give the program one or more input files as arguments. It works with most media files.
**How do I specify the output?**
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.
Example:
```
ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav
```
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`.
Using the `-ext` option, you can supply a different output extension common to all output files, e.g. `-ext m4a`.
**What will get normalized?**
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.
**How will the normalization be done?**
The normalization will be performed with the [`loudnorm` filter](http://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.
**What codec is chosen?**
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.
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).
## Examples
[Read the examples on the the wiki.](https://github.com/slhck/ffmpeg-normalize/wiki/examples)
## Detailed Options
### File Input/Output
- `input`: Input media file(s)
- `-o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]`: Output file names.
Will be applied per input file.
If no output file name is specified for an input file, the output files
will be written to the default output folder with the name `<input>.<ext>`, where `<ext>` is the output extension (see `-ext` option).
Example: `ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav`
- `-of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER`: Output folder (default: `normalized`)
This folder will be used for input files that have no explicit output name specified.
### General
- `-f, --force`: Force overwrite existing files
- `-d, --debug`: Print debugging output
- `-v, --verbose`: Print verbose output
- `-q, --quiet`: Only print errors
- `-n, --dry-run`: Do not run normalization, only print what would be done
- `-pr`, `--progress`: Show progress bar for files and streams
- `--version`: Print version and exit
### Normalization
- `-nt {ebu,rms,peak}, --normalization-type {ebu,rms,peak}`: Normalization type (default: `ebu`).
EBU normalization performs two passes and normalizes according to EBU R128.
RMS-based normalization brings the input file to the specified RMS level.
Peak normalization brings the signal to the specified peak level.
- `-t TARGET_LEVEL, --target-level TARGET_LEVEL`: Normalization target level in dB/LUFS (default: -23).
For EBU normalization, it corresponds to Integrated Loudness Target in LUFS. The range is -70.0 - -5.0.
Otherwise, the range is -99 to 0.
- `-p, --print-stats`: Print first pass loudness statistics formatted as JSON to stdout.
### EBU R128 Normalization
- `-lrt LOUDNESS_RANGE_TARGET, --loudness-range-target LOUDNESS_RANGE_TARGET`: EBU Loudness Range Target in LUFS (default: 7.0).
Range is 1.0 - 50.0.
- `--keep-loudness-range-target`: Keep the input loudness range target to allow for linear normalization.
- `-tp TRUE_PEAK, --true-peak TRUE_PEAK`: EBU Maximum True Peak in dBTP (default: -2.0).
Range is -9.0 - +0.0.
- `--offset OFFSET`: EBU Offset Gain (default: 0.0).
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.
Range is -99.0 - +99.0.
- `--dual-mono`: Treat mono input files as "dual-mono".
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.
- `--dynamic`: Force dynamic normalization mode.
Instead of applying linear EBU R128 normalization, choose a dynamic normalization. This is not usually recommended.
Dynamic mode will automatically change the sample rate to 192 kHz. Use -ar/--sample-rate to specify a different output sample rate.
### Audio Encoding
- `-c:a AUDIO_CODEC, --audio-codec AUDIO_CODEC`: Audio codec to use for output files.
See `ffmpeg -encoders` for a list.
Will use PCM audio with input stream bit depth by default.
- `-b:a AUDIO_BITRATE, --audio-bitrate AUDIO_BITRATE`: Audio bitrate in bits/s, or with K suffix.
If not specified, will use codec default.
- `-ar SAMPLE_RATE, --sample-rate SAMPLE_RATE`: Audio sample rate to use for output files in Hz.
Will use input sample rate by default, except for EBU normalization, which will change the input sample rate to 192 kHz.
- `-koa, --keep-original-audio`: Copy original, non-normalized audio streams to output file
- `-prf PRE_FILTER, --pre-filter PRE_FILTER`: Add an audio filter chain before applying normalization.
Multiple filters can be specified by comma-separating them.
- `-pof POST_FILTER, --post-filter POST_FILTER`: Add an audio filter chain after applying normalization.
Multiple filters can be specified by comma-separating them.
For EBU, the filter will be applied during the second pass.
### Other Encoding Options
- `-vn, --video-disable`: Do not write video streams to output
- `-c:v VIDEO_CODEC, --video-codec VIDEO_CODEC`: Video codec to use for output files (default: 'copy').
See `ffmpeg -encoders` for a list.
Will attempt to copy video codec by default.
- `-sn, --subtitle-disable`: Do not write subtitle streams to output
- `-mn, --metadata-disable`: Do not write metadata to output
- `-cn, --chapters-disable`: Do not write chapters to output
### Input/Output Format
- `-ei EXTRA_INPUT_OPTIONS, --extra-input-options EXTRA_INPUT_OPTIONS`: Extra input options list.
A list of extra ffmpeg command line arguments valid for the input, applied before ffmpeg's `-i`.
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.
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=`.
Examples: `-ei '[ "-f", "mpegts", "-r", "24" ]'` or `-ei="-f mpegts -r 24"`
- `-e EXTRA_OUTPUT_OPTIONS, --extra-output-options EXTRA_OUTPUT_OPTIONS`: Extra output options list.
A list of extra ffmpeg command line arguments valid for the output.
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.
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=`.
Examples: `-e '[ "-vbr", "3", "-preset:v", "ultrafast" ]'` or `-e="-vbr 3 -preset:v ultrafast"`
- `-ofmt OUTPUT_FORMAT, --output-format OUTPUT_FORMAT`: Media format to use for output file(s).
See `ffmpeg -formats` for a list.
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).
- `-ext EXTENSION, --extension EXTENSION`: Output file extension to use for output files that were not explicitly specified. (Default: `mkv`)
### Environment Variables
The program additionally respects environment variables:
- `TMP` / `TEMP` / `TMPDIR`
Sets the path to the temporary directory in which files are
stored before being moved to the final output directory.
Note: You need to use full paths.
- `FFMPEG_PATH`
Sets the full path to an `ffmpeg` executable other than
the system default or you can provide a file name available on $PATH
## API
This program has a simple API that can be used to integrate it into other Python programs.
For more information see the [API documentation](https://htmlpreview.github.io/?https://github.com/slhck/ffmpeg-normalize/blob/master/docs/ffmpeg_normalize.html).
## FAQ
### The program doesn't work because the "loudnorm" filter can't be found
Make sure you run ffmpeg v3.1 or higher and that `loudnorm` is part of the output when you run `ffmpeg -filters`. Many distributions package outdated ffmpeg 2.x versions, or (even worse), Libav's `ffmpeg` disguising as a real `ffmpeg` from the FFmpeg project.
Some ffmpeg builds also do not have the `loudnorm` filter enabled.
You can always download a static build from [their website](http://ffmpeg.org/download.html) and use that.
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.
### Should I use this to normalize my music collection?
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/).
### Why are my output files MKV?
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.
### "Could not write header for output file" error
See the [next section](#the-conversion-does-not-work-and-i-get-a-cryptic-ffmpeg-error).
### The conversion does not work and I get a cryptic ffmpeg error!
Maybe ffmpeg says something like:
> Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Or the program says:
> β¦ Please choose a suitable audio codec with the `-c:a` option.
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:
- 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`).
- 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`).
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).
Also, if there is some other broken metadata, you can try to disable copying over of metadata with `-mn`.
Finally, make sure you use a recent version of ffmpeg. The [static builds](https://ffmpeg.org/download.html) are usually the best option.
### What are the different normalization algorithms?
- **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.
- **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.
- **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.
### Couldn't I just run `loudnorm` with ffmpeg?
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.
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.
If you want dynamic normalization (the loudnorm default), simply use ffmpeg with one pass, e.g.:
```bash
ffmpeg -i input.mp3 -af loudnorm -c:a aac -b:a 192k output.m4a
```
### What about speech?
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.
See [the documentation](https://ffmpeg.org/ffmpeg-all.html#speechnorm) for more information.
### After updating, this program does not work as expected anymore!
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.
### Can I buy you a beer / coffee / random drink?
If you found this program useful and feel like giving back, feel free to send a donation [via PayPal](https://paypal.me/WernerRobitza).
## Related Tools and Articles
- [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/)
*(Have a link? Please propose an edit to this section via a pull request!)*
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://overtag.dk/"><img src="https://avatars.githubusercontent.com/u/374612?v=4?s=100" width="100px;" alt="Benjamin Balder Bach"/><br /><sub><b>Benjamin Balder Bach</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=benjaoming" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://chaos.social/@eleni"><img src="https://avatars.githubusercontent.com/u/511547?v=4?s=100" width="100px;" alt="Eleni Lixourioti"/><br /><sub><b>Eleni Lixourioti</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Geekfish" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/thenewguy"><img src="https://avatars.githubusercontent.com/u/77731?v=4?s=100" width="100px;" alt="thenewguy"/><br /><sub><b>thenewguy</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=thenewguy" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/aviolo"><img src="https://avatars.githubusercontent.com/u/560229?v=4?s=100" width="100px;" alt="Anthony Violo"/><br /><sub><b>Anthony Violo</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=aviolo" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://jacobs.af/"><img src="https://avatars.githubusercontent.com/u/952830?v=4?s=100" width="100px;" alt="Eric Jacobs"/><br /><sub><b>Eric Jacobs</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=jetpks" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kostalski"><img src="https://avatars.githubusercontent.com/u/34033008?v=4?s=100" width="100px;" alt="kostalski"/><br /><sub><b>kostalski</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=kostalski" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://justinppearson.com/"><img src="https://avatars.githubusercontent.com/u/8844823?v=4?s=100" width="100px;" alt="Justin Pearson"/><br /><sub><b>Justin Pearson</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=justinpearson" title="Code">π»</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Nottt"><img src="https://avatars.githubusercontent.com/u/13532436?v=4?s=100" width="100px;" alt="ad90xa0-aa"/><br /><sub><b>ad90xa0-aa</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Nottt" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Mathijsz"><img src="https://avatars.githubusercontent.com/u/1891187?v=4?s=100" width="100px;" alt="Mathijs"/><br /><sub><b>Mathijs</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Mathijsz" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mpuels"><img src="https://avatars.githubusercontent.com/u/2924816?v=4?s=100" width="100px;" alt="Marc PΓΌls"/><br /><sub><b>Marc PΓΌls</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=mpuels" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.mvbattista.com/"><img src="https://avatars.githubusercontent.com/u/158287?v=4?s=100" width="100px;" alt="Michael V. Battista"/><br /><sub><b>Michael V. Battista</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=mvbattista" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://auto-editor.com"><img src="https://avatars.githubusercontent.com/u/57511737?v=4?s=100" width="100px;" alt="WyattBlue"/><br /><sub><b>WyattBlue</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=WyattBlue" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/g3n35i5"><img src="https://avatars.githubusercontent.com/u/17593457?v=4?s=100" width="100px;" alt="Jan-Frederik Schmidt"/><br /><sub><b>Jan-Frederik Schmidt</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=g3n35i5" title="Code">π»</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="7">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## License
The MIT License (MIT)
Copyright (c) 2015-2022 Werner Robitza
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Changelog
## v1.26.6 (2023-03-16)
* Production status stable.
* Make install_requires more abstract.
## v1.26.5 (2023-03-15)
* Add "-hide_banner" remove "-nostdin" (#222)
The `-nostdin` option is unnessary because of the `-y` option.
Adding `-hide_banner` makes DEBUG statements shorter.
* Homebrew works on linux too.
* Explain ffmpeg installation steps.
## v1.26.4 (2023-02-08)
* Re-add requirements.txt to (maybe) fix conda-forge builds.
## v1.26.3 (2023-02-08)
* Fix requirements (#218)
* Improve types.
* Docs: add @g3n35i5 as a contributor.
## v1.26.2 (2023-02-06)
* Add ignore-revs file.
* Formatting and import sorting.
* Refactor: Improved logging behavior (#216)
* Add "apt update" (#215)
* Remove stalebot.
* Update README.
* Move to_ms and make CommandRunner more ergonomic (#212)
* Upgrade workflow, get ffmpeg from apt (#213)
* Turn FFmpegNormalizeError into a normal Exception (#211)
* Remove manifest.in (#210)
* Simplify logging (#209)
* Use pep585 type hints (#207)
* Don't use tempfile's private module function (#206)
* Fix smaller type errors.
* Reduce mypy errors 12 -> 4 (#204)
* Make input validation more efficient.
Make input validation more efficient
Re-separate formats and exts
## v1.26.1 (2022-12-18)
* Bump requirements.
* Add py.typed support.
* General refactoring + type hints (#202)
* Re-write to f-strings when possible (#201)
* Remove unnecessary utf-8 declarations (#200)
"-*- coding: utf-8 -*-" is a Python 2 construct and can be safely
removed. Other utf-8 declarations are also unnecessary.
## v1.26.0 (2022-12-14)
* Add .editorconfig.
* Link to API docs.
* Add docs.
* Add type hints, document everything, refactor some code.
* Add more audio formats (#199)
* Add python 3.11 to CI.
* Docs: add WyattBlue as a contributor for code (#198)
* docs: update README.md
* docs: update .all-contributorsrc
* Upgrade to Python 3.8 syntax (#197)
* Fix python version in github tests.
* Bump requirements to latest versions.
* Add python 3.11 to list of languages.
* Bump required python version to 3.8.
* Various minor code cleanups and type hints.
* Harmonize logger code.
* Update python version in tests.
* Docs: add @mvbattista as a contributor.
* Docs: add @mpuels as a contributor.
* Docs: add @Mathijsz as a contributor.
* Docs: add @Nottt as a contributor.
* Docs: add @justinpearson as a contributor.
* Docs: add @kostalski as a contributor.
* Docs: add @jetpks as a contributor.
* Docs: add @aviolo as a contributor.
* Docs: add @thenewguy as a contributor.
* Docs: add @Geekfish as a contributor.
* Docs: add @benjaoming as a contributor.
* Reference speechnorm.
## v1.25.3 (2022-11-09)
* Update README.
* Update list of pcm-incompatible extensions.
## v1.25.2 (2022-09-14)
* Constrain parsed ranges to avoid out of bounds, fixes #189.
* Fix readme for extra-input-options.
* Warn about dynamic mode only if not already set, fixes #187.
## v1.25.1 (2022-08-21)
* Add warning in case user specifies both --lrt and --keep-loudness-range-target.
## v1.25.0 (2022-08-20)
* Add option to keep loudness range target, fixes #181.
* Only show warning about disabling video if not yet disabled, addresses #184.
## v1.24.1 (2022-08-20)
* Code formatting.
* Extend warning for audio-only format to opus, fixes #184.
## v1.24.0 (2022-08-02)
* Update python requirements.
* Prevent race condition in output dir creation.
## v1.23.1 (2022-07-12)
* Increase possible loudness range target to 50.
## v1.23.0 (2022-05-01)
* Add way to force dynamic mode, clarify usage, fixes #176.
## v1.22.10 (2022-04-25)
* Add warning for cover art, addresses #174 and #175.
* Update README.
## v1.22.9 (2022-04-17)
* Improve issue templates.
* Do not print ffmpeg progress in debug logs.
* Remove unused import.
* Replace which() function with shlex version.
* Add python 3.10 in setup.py.
* Clarify minimum ffmpeg version.
## v1.22.8 (2022-03-07)
* Properly detect -inf dB input.
## v1.22.7 (2022-02-25)
* Debug command output for ffmpeg commands.
* Remove unneeded warning message.
## v1.22.6 (2022-02-20)
* Use astats instead of volumedetect filter, fixes #163.
Allows floating point calculation.
## v1.22.5 (2022-01-25)
* Print warning for bit depths > 16, addresses #163.
## v1.22.4 (2021-10-18)
* Re-raise error on ffmpeg command failure.
This prevents incorrectly telling the user that a normalized file was written when it wasn't.
## v1.22.3 (2021-08-31)
* Set tqdm lock for logging only when multiprocessing is available.
Multiprocessing is not available in all environments, for example
on AWS lambda python run time lacks /dev/shm, so trying to acquire
a multiprocessing Lock throws an OSError. The module could also be
missing in some cases (ex. Jython, although this library doesn't support
Jython anyway).
The solution to this is to only try to set the lock when multiprocessing
is available. The tqdm library solves this in the same manner.
For more details: https://github.com/slhck/ffmpeg-normalize/issues/156
* Add instructions on how to run tests.
## v1.22.2 (2021-08-14)
* Bump requirements, should fix #155.
* Move all examples to Wiki.
* Update badge link.
## v1.22.1 (2021-03-10)
* Add python_requires to setup.py.
## v1.22.0 (2021-03-09)
* Improve README.
* Add GitHub actions badge.
* Add GitHub actions tests.
* Properly convert EBU JSON values to float.
* Switch to f strings, remove Python 3.5 support.
* Format code with black.
* Fix flake8 errors.
* Factor out method.
* WIP: new tests.
* Log to stderr by default to enable JSON parsing.
* Remove release script.
## v1.21.2 (2021-03-06)
* Format setup.py.
* Switch progress to external lib.
* Remove support for older versions.
## v1.21.1 (2021-03-05)
* Adjusted handling of FFMPEG_PATH for binaries available via $PATH (#149)
* adjusted handling of FFMPEG_PATH for binaries available via $PATH
fixes #147
* adjusted use of %s to {} to match style
* documented the feature
* condensed error message as other lines are longer
## v1.21.0 (2021-02-27)
* Fix JSON output for multiple files.
* Update badge URL.
* Update README.md (#142)
* Update README.md
Added example of verifying levels
Fixes #141
* shorten example, add link to wiki page
* Error if no ffmpeg exec exists.
* Add stalebot.
## v1.20.2 (2020-11-06)
* Fixing stdin corruption caused by new subprocess (#138)
* Update issue template.
* Create FUNDING.yml.
* Fix usage, addresses #132.
## v1.20.1 (2020-07-22)
* Manually specify usage string, fixes #132.
* Fix local import for tests.
## v1.20.0 (2020-07-04)
* Add extra input options.
## v1.19.1 (2020-06-25)
* Add colorama to requirements, fixes #131.
* Fix warning that is printed with default options.
## v1.19.0 (2020-05-02)
* Fix issue with output folder, fixes #126.
* Fix typo in README's table of contents link to "File Input/Output". (#124)
* Clarify readme, fixes #122.
## v1.18.2 (2020-04-19)
* Add warning for automatic sample rate conversion, addresses #122.
* Ignore vscode folder.
* Fix printing of errors in conversion.
## v1.18.1 (2020-04-16)
* Fix unit tests.
* Improve handling of output file folder and errors.
* Clarify usage of output options, add warning.
* Improve documentation, fixes #120.
* Do not include bump messages in changelog.
## v1.18.0 (2020-04-13)
* Use measured offset in second pass, fixes #119.
* Update release instructions.
* Remove author names from changelog.
## v1.17.0 (2020-04-10)
* Update release script and changelog template.
* Apply pre-filters in all first passes, fixes #118.
This allows properly reading the level for any kind of normalization, even if
filters affect the loudness in the first pass.
## v1.16.0 (2020-04-07)
* Add all commits to changelog.
* Remove python 2 support.
* Add quiet option, fixes #116.
- Add a new quiet option
- Promote some warnings to actual errors that need to be shown
- Add a very basic test case
## v1.15.8 (2020-03-15)
* Improve release script.
* Python 3.8.
## v1.15.7 (2020-03-14)
* Only print length warning for non-EBU type normalization.
## v1.15.6 (2019-12-04)
* Remove build and dist folder on release.
* Do not exit on error in batch processing.
Simply process the next file if one has errors, addresses #110.
## v1.15.5 (2019-11-19)
* Use minimal dependency for tqdm.
* Remove specific python version requirement.
## v1.15.4 (2019-11-19)
* Freeze tqdm version.
* Update python to 3.7.
* Improve release documentation.
## v1.15.3 (2019-10-15)
* Do not print stream warning when there is only one stream.
* Remove previous dist versions before release.
## v1.15.2 (2019-07-12)
* Warn when duration cannot be read, fixes #105.
* Update README.
minor improvements in the description
## v1.15.1 (2019-06-17)
* Add output to unit test failures.
* Fix input label for audio stream.
## v1.15.0 (2019-06-17)
* Add pre-and post-filter hooks, fixes #67.
This allows users to specify filters to be run before or after the actual
normalization call, using regular ffmpeg syntax.
Only applies to audio.
* Document audiostream class.
* Warn when file is too short, fixes #87.
* Update release method to twine.
## v1.14.1 (2019-06-14)
* Handle progress output from ffmpeg, fixes #10.
* Merge pull request #99 from Nottt/patch-1.
fix -cn description
* Fix -cn description.
* Add nicer headers for options in README.
## v1.14.0 (2019-04-24)
* Add version file in release script before committing.
* Add option to keep original audio, fixes #83.
* Add pypi badge.
* Allow release script to add changelog for future version; upload to pypi.
## v1.13.11 (2019-04-16)
* Add release script.
* Add small developer guide on releasing.
* Move HISTORY.md to CHANGELOG.md.
* Fix ffmpeg static build download location.
## v1.3.10 (2019-02-22)
* Bump version.
* Cap measured input loudness, fixes #92.
## v1.3.9 (2019-01-10)
* Bump version.
* Fix handling of errors with tqdm.
* Improve readme.
* Delete issue template.
* Bump version.
* Clarify extra argument options, move to main entry point.
* Update issue templates.
## v1.3.8 (2018-11-28)
* Bump version.
* Clarify extra argument options, move to main entry point.
## v1.3.7 (2018-10-28)
* Bump version.
* Copy metadata from individual streams, fixes #86.
* Add python version for pyenv.
## v1.3.6 (2018-07-09)
* Bump version.
* Update README, fixes #79 and addresses #80.
## v1.3.5 (2018-06-12)
* Bump version.
* Minor README updates.
* Fix documentation of TMPDIR parameter.
## v1.3.4 (2018-05-05)
* Bump version.
* New way to specify extra options.
## v1.3.3 (2018-05-05)
* Update README.
* Decode strings in extra options.
## v1.3.2 (2018-04-25)
* Bump version.
* Merge pull request #69 from UbiCastTeam/master.
Stderror decoding ignoring utf8 encoding errors
* Stderror decoding ignoring utf8 encoding errors.
## v1.3.1 (2018-04-24)
* Bump version.
* Do not require main module in setup.py, fixes #68.
## v1.3.0 (2018-04-15)
* Bump version.
* Remove dead code.
* Fix for python2 division.
* Update documentation.
* Progress bar.
* Remove imports from test file.
* Fix travis file.
* WIP: progress bar.
* Minor typo in option group.
* Add simple unit test for disabling chapters.
## v1.2.3 (2018-04-11)
* Fix unit test.
* Bump version.
* Add option to disable chapters, fixes #65, also fix issue with metadata.
## v1.2.2 (2018-04-10)
* Bump version.
* Set default loudness target to -23, fixes #48.
## v1.2.1 (2018-04-04)
* Bump version.
* Merge pull request #64 from UbiCastTeam/encoding-issue.
Stdout and stderror decoding ignoring utf8 encoding errors
* Stdout and stderror decoding ignoring utf8 encoding errors.
## v1.2.0 (2018-03-22)
* Bump version.
* Add errors for impossible format combinations, fixes #60.
* Fix ordering of output maps, fixes #63.
* Improve documentation.
## v1.1.0 (2018-03-06)
* Add option to print first pass statistics.
## v1.0.10 (2018-03-04)
* Bump version.
* Restrict parsing to valid JSON part only, fixes #61.
* Add an example for MP3 encoding.
* Update paypal link.
## v1.0.9 (2018-02-08)
* Bump version.
* Add normalized folder to gitignore.
* Do not print escape sequences on Windows.
* Do not check for file existence, fixes #57.
* Add github issue template.
## v1.0.8 (2018-02-01)
* Bump version.
* Do not check for ffmpeg upon module import.
## v1.0.7 (2018-02-01)
* Bump version.
* Rename function test.
* Fix issue with wrong adjustment parameters, fixes #54.
## v1.0.6 (2018-01-30)
* Allow setting FFMPEG_PATH and document TMP.
## v1.0.5 (2018-01-26)
* Handle edge case for short input clips.
## v1.0.4 (2018-01-26)
* Bump version.
* Do not try to remove nonexisting file in case of error in command.
## v1.0.3 (2018-01-26)
* Bump version.
* Always streamcopy when detecting streams to avoid initializing encoder.
* Fix handling of temporary file.
* Add build status.
* Travis tests.
## v1.0.2 (2018-01-25)
* Fix bug with target level for peak/RMS.
* Update documentation formatting.
* Update history.
## v1.0.1 (2018-01-24)
* Bump version.
* Set default target to -23.
## v1.0.0 (2018-01-23)
* Add version info and test case for dry run.
* New feature detection, add documentation, contributors guide etc.
* WIP: v1.0 rewrite.
## v0.7.3 (2017-10-09)
* Use shutil.move instead of os.rename.
## v0.7.2 (2017-09-17)
* Allow setting threshold to 0.
## v0.7.1 (2017-09-14)
* Bump version.
* Update HISTORY.md.
* Merge pull request #37 from Mathijsz/fix-which-path-expansion.
expand tilde and environment variables, fixes #36
* Expand tilde and environment variables, fixes #36.
* Update HISTORY.md.
* Update README w.r.t. loudnorm filter.
* Update README and indentation.
## v0.7.0 (2017-08-02)
* Bump version.
* Fix handling of extra options with spaces.
* Include test script.
* Logging and other improvements.
* Add test files.
* Autopep8 that thing.
* Logger improvements.
* Add example for overwriting.
## v0.6.0 (2017-07-31)
* Allow overwriting input file, fixes #22.
* Version bump.
* Better handle cmd arguments.
* Update README.md.
add another example
## v0.5.1 (2017-04-04)
* Fix for problem introduced in 304e8df.
## v0.5 (2017-04-02)
* Fix pypi topics.
* Bump version and README.
* Fix issue where output was wrong format.
* Add EBU R128 filter.
* Use Markdown instead of RST for README/HISTORY.
* Define file encode for python3, fixes #24.
* Fix history.
* Fix option -np.
* Clarify merge option.
* Minor documentation improvements.
- change README from CRLF to LF
- add "attenuated" in description
- extend LICENSE year
- add license to main README
## v0.4.1 (2017-02-13)
* Update for release.
* Merge pull request #21 from mpuels/patch-1.
Fix for #13
* Fix for #13.
* Mention Python 3.
mention that Python 3 may work, just didn't have time to test
* Fix README's code blocks.
## v0.4 (2017-01-24)
* Code cleanup, add option to set format and audio codec.
## v0.3 (2017-01-19)
* Add option for no prefix, fixes #20.
* Handle multiple spaces in path; fixes issue #18.
* Handle spaces in path, fixes #12.
* Update README.rst.
* Change default level back to -26.
* Typo in README example.
* Update documentation.
* Bump to v0.2.0.
* Support for multiple files and output directories.
* Support merging of audio with input file
* Set audio codec and additional options
* User-definable threshold
* Better error handling and logging
* Deprecates avconv
* Change default level back to -28.
* Merge pull request #15 from auricgoldfinger/master.
Add extended normalisation options
* Add extended normalisation options.
- add program option to write output in a separate directory in stead of
prefixing it
- add program option to merge the normalized audio in the original
(video) file rather than creating a separate WAV file
- change the maximum setting: will now normalize so that max
volume is set to 0, adjusted with the given level.
e.g. : -m -l -5 will increase the audio level to max = -5.0dB
- improve verbose logging: number of files are written to the
info log
- improve performance: check first whether the output file
exists before calculating the volume levels + not modifying
the file if the adjustment < 0.5dB (level is never exactly 0)
* Update README, fixes #11.
## v0.1.3 (2015-12-15)
* Check for Windows .exe, fixes #10.
* Check path and fix #9.
* Merge pull request #8 from benjaoming/master.
Add MANIFEST.in
* Bump version.
* Add manifest to include missing files in sdist.
* Merge pull request #6 from jetpks/master.
Fixed ffmpeg v2.6.3 compatibility and docopt config
* Updated to work with ffmpeg v2.6.3, and fixed broken docopt config.
ffmpeg update:
ffmpeg v2.6.3 puts mean_volume on stderr instead of stdout, causing
`output` in `ffmpeg_get_mean` to be completely empty, and no match for
mean_volume or max_volume to be found.
Fixed by adding `stderr=subprocess.PIPE` in both Popen calls in
`run_command`, and combining stdout and stderr on return. We already
exit with non-zero return, so combining stderr/stdout shouldn't cause
any poor side-effects.
docopt config:
- args['--level'] was not recognizing its default because there was
an errant comma between -l and --level, and it needed <level> after
the arguments.
- Fixed spacing for --max
- Removed quotes around 'normalized' so single quote characters don't
end up in the output file names.
* Removed Windows carraige returns from __main__.py.
* Merge pull request #5 from mvbattista/master.
Installation update to ffmpeg
* Installation update to ffmpeg.
* Update to ffmpeg.
* Update HISTORY.rst.
* Update to ffmpeg.
* Merge pull request #4 from benjaoming/rename.
Rename project
* Make at least one file mandatory.
* Rename project and remove pyc file.
* Merge pull request #2 from benjaoming/docopt-setuptools-avconv.
Docopt, Setuptools, avconv compatibility
* Use docopt.
* Use normalize-audio when using avconv because it doesn't have a way to measure volume.
* Functional setup.py, communicate with avconv/ffmpeg about overwriting.
* Also detect avconv.
* Use a main function instead.
* Add a history for the project.
* Move to more unique module name.
* Update README.rst.
* Change the README to rst (PyPi)
* Delete .gitignore.
* Update README.md.
* Various improvements, fixes #1.
* License.
* Livense.
* Update README.md.
* Merge branch 'master' of https://github.com/slhck/audio-normalize.
* Initial commit.
* Initial commit.
%package help
Summary: Development documents and examples for ffmpeg-normalize
Provides: python3-ffmpeg-normalize-doc
%description help
## Requirements
You need Python 3.8 or higher.
### ffmpeg
- ffmpeg 5.x is required
- Download a [static build](https://ffmpeg.org/download.html) for your system
- Place the `ffmpeg` executable in your `$PATH`, or specify the path to the binary with the `FFMPEG_PATH` environment variable in `ffmpeg-normalize`
For instance, under Linux:
```bash
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
mkdir -p ffmpeg
tar -xf ffmpeg-release-amd64-static.tar.xz -C ffmpeg --strip-components=1
sudo cp ffmpeg/ffmpeg /usr/local/bin
sudo cp ffmpeg/ffprobe /usr/local/bin
sudo chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe
```
For Windows, follow [this guide](https://www.wikihow.com/Install-FFmpeg-on-Windows).
For macOS and Linux, you can also use [Homebrew](https://brew.sh):
```bash
brew install ffmpeg
```
Note that using distribution packages (e.g., `apt install ffmpeg`) is not recommended, as these are often outdated.
## Installation
For Python 3 and pip:
```bash
pip3 install ffmpeg-normalize
```
Or download this repository, then run `pip3 install .`.
## Usage
```
ffmpeg-normalize [-h]
[-o OUTPUT [OUTPUT ...]] [-of OUTPUT_FOLDER]
[-f] [-d] [-v] [-q] [-n] [-pr]
[--version]
[-nt {ebu,rms,peak}]
[-t TARGET_LEVEL] [-p] [-lrt LOUDNESS_RANGE_TARGET] [-tp TRUE_PEAK] [--offset OFFSET] [--dual-mono] [--dynamic]
[-c:a AUDIO_CODEC] [-b:a AUDIO_BITRATE] [-ar SAMPLE_RATE] [-koa]
[-prf PRE_FILTER] [-pof POST_FILTER]
[-vn] [-c:v VIDEO_CODEC]
[-sn] [-mn] [-cn]
[-ei EXTRA_INPUT_OPTIONS] [-e EXTRA_OUTPUT_OPTIONS]
[-ofmt OUTPUT_FORMAT] [-ext EXTENSION]
input [input ...]
```
For more information, run `ffmpeg-normalize -h`, or read on.
## Description
Please read this section for a high level introduction.
**What does the program do?**
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.
**How do I specify the input?**
Just give the program one or more input files as arguments. It works with most media files.
**How do I specify the output?**
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.
Example:
```
ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav
```
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`.
Using the `-ext` option, you can supply a different output extension common to all output files, e.g. `-ext m4a`.
**What will get normalized?**
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.
**How will the normalization be done?**
The normalization will be performed with the [`loudnorm` filter](http://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.
**What codec is chosen?**
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.
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).
## Examples
[Read the examples on the the wiki.](https://github.com/slhck/ffmpeg-normalize/wiki/examples)
## Detailed Options
### File Input/Output
- `input`: Input media file(s)
- `-o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]`: Output file names.
Will be applied per input file.
If no output file name is specified for an input file, the output files
will be written to the default output folder with the name `<input>.<ext>`, where `<ext>` is the output extension (see `-ext` option).
Example: `ffmpeg-normalize 1.wav 2.wav -o 1n.wav 2n.wav`
- `-of OUTPUT_FOLDER, --output-folder OUTPUT_FOLDER`: Output folder (default: `normalized`)
This folder will be used for input files that have no explicit output name specified.
### General
- `-f, --force`: Force overwrite existing files
- `-d, --debug`: Print debugging output
- `-v, --verbose`: Print verbose output
- `-q, --quiet`: Only print errors
- `-n, --dry-run`: Do not run normalization, only print what would be done
- `-pr`, `--progress`: Show progress bar for files and streams
- `--version`: Print version and exit
### Normalization
- `-nt {ebu,rms,peak}, --normalization-type {ebu,rms,peak}`: Normalization type (default: `ebu`).
EBU normalization performs two passes and normalizes according to EBU R128.
RMS-based normalization brings the input file to the specified RMS level.
Peak normalization brings the signal to the specified peak level.
- `-t TARGET_LEVEL, --target-level TARGET_LEVEL`: Normalization target level in dB/LUFS (default: -23).
For EBU normalization, it corresponds to Integrated Loudness Target in LUFS. The range is -70.0 - -5.0.
Otherwise, the range is -99 to 0.
- `-p, --print-stats`: Print first pass loudness statistics formatted as JSON to stdout.
### EBU R128 Normalization
- `-lrt LOUDNESS_RANGE_TARGET, --loudness-range-target LOUDNESS_RANGE_TARGET`: EBU Loudness Range Target in LUFS (default: 7.0).
Range is 1.0 - 50.0.
- `--keep-loudness-range-target`: Keep the input loudness range target to allow for linear normalization.
- `-tp TRUE_PEAK, --true-peak TRUE_PEAK`: EBU Maximum True Peak in dBTP (default: -2.0).
Range is -9.0 - +0.0.
- `--offset OFFSET`: EBU Offset Gain (default: 0.0).
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.
Range is -99.0 - +99.0.
- `--dual-mono`: Treat mono input files as "dual-mono".
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.
- `--dynamic`: Force dynamic normalization mode.
Instead of applying linear EBU R128 normalization, choose a dynamic normalization. This is not usually recommended.
Dynamic mode will automatically change the sample rate to 192 kHz. Use -ar/--sample-rate to specify a different output sample rate.
### Audio Encoding
- `-c:a AUDIO_CODEC, --audio-codec AUDIO_CODEC`: Audio codec to use for output files.
See `ffmpeg -encoders` for a list.
Will use PCM audio with input stream bit depth by default.
- `-b:a AUDIO_BITRATE, --audio-bitrate AUDIO_BITRATE`: Audio bitrate in bits/s, or with K suffix.
If not specified, will use codec default.
- `-ar SAMPLE_RATE, --sample-rate SAMPLE_RATE`: Audio sample rate to use for output files in Hz.
Will use input sample rate by default, except for EBU normalization, which will change the input sample rate to 192 kHz.
- `-koa, --keep-original-audio`: Copy original, non-normalized audio streams to output file
- `-prf PRE_FILTER, --pre-filter PRE_FILTER`: Add an audio filter chain before applying normalization.
Multiple filters can be specified by comma-separating them.
- `-pof POST_FILTER, --post-filter POST_FILTER`: Add an audio filter chain after applying normalization.
Multiple filters can be specified by comma-separating them.
For EBU, the filter will be applied during the second pass.
### Other Encoding Options
- `-vn, --video-disable`: Do not write video streams to output
- `-c:v VIDEO_CODEC, --video-codec VIDEO_CODEC`: Video codec to use for output files (default: 'copy').
See `ffmpeg -encoders` for a list.
Will attempt to copy video codec by default.
- `-sn, --subtitle-disable`: Do not write subtitle streams to output
- `-mn, --metadata-disable`: Do not write metadata to output
- `-cn, --chapters-disable`: Do not write chapters to output
### Input/Output Format
- `-ei EXTRA_INPUT_OPTIONS, --extra-input-options EXTRA_INPUT_OPTIONS`: Extra input options list.
A list of extra ffmpeg command line arguments valid for the input, applied before ffmpeg's `-i`.
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.
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=`.
Examples: `-ei '[ "-f", "mpegts", "-r", "24" ]'` or `-ei="-f mpegts -r 24"`
- `-e EXTRA_OUTPUT_OPTIONS, --extra-output-options EXTRA_OUTPUT_OPTIONS`: Extra output options list.
A list of extra ffmpeg command line arguments valid for the output.
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.
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=`.
Examples: `-e '[ "-vbr", "3", "-preset:v", "ultrafast" ]'` or `-e="-vbr 3 -preset:v ultrafast"`
- `-ofmt OUTPUT_FORMAT, --output-format OUTPUT_FORMAT`: Media format to use for output file(s).
See `ffmpeg -formats` for a list.
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).
- `-ext EXTENSION, --extension EXTENSION`: Output file extension to use for output files that were not explicitly specified. (Default: `mkv`)
### Environment Variables
The program additionally respects environment variables:
- `TMP` / `TEMP` / `TMPDIR`
Sets the path to the temporary directory in which files are
stored before being moved to the final output directory.
Note: You need to use full paths.
- `FFMPEG_PATH`
Sets the full path to an `ffmpeg` executable other than
the system default or you can provide a file name available on $PATH
## API
This program has a simple API that can be used to integrate it into other Python programs.
For more information see the [API documentation](https://htmlpreview.github.io/?https://github.com/slhck/ffmpeg-normalize/blob/master/docs/ffmpeg_normalize.html).
## FAQ
### The program doesn't work because the "loudnorm" filter can't be found
Make sure you run ffmpeg v3.1 or higher and that `loudnorm` is part of the output when you run `ffmpeg -filters`. Many distributions package outdated ffmpeg 2.x versions, or (even worse), Libav's `ffmpeg` disguising as a real `ffmpeg` from the FFmpeg project.
Some ffmpeg builds also do not have the `loudnorm` filter enabled.
You can always download a static build from [their website](http://ffmpeg.org/download.html) and use that.
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.
### Should I use this to normalize my music collection?
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/).
### Why are my output files MKV?
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.
### "Could not write header for output file" error
See the [next section](#the-conversion-does-not-work-and-i-get-a-cryptic-ffmpeg-error).
### The conversion does not work and I get a cryptic ffmpeg error!
Maybe ffmpeg says something like:
> Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Or the program says:
> β¦ Please choose a suitable audio codec with the `-c:a` option.
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:
- 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`).
- 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`).
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).
Also, if there is some other broken metadata, you can try to disable copying over of metadata with `-mn`.
Finally, make sure you use a recent version of ffmpeg. The [static builds](https://ffmpeg.org/download.html) are usually the best option.
### What are the different normalization algorithms?
- **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.
- **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.
- **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.
### Couldn't I just run `loudnorm` with ffmpeg?
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.
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.
If you want dynamic normalization (the loudnorm default), simply use ffmpeg with one pass, e.g.:
```bash
ffmpeg -i input.mp3 -af loudnorm -c:a aac -b:a 192k output.m4a
```
### What about speech?
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.
See [the documentation](https://ffmpeg.org/ffmpeg-all.html#speechnorm) for more information.
### After updating, this program does not work as expected anymore!
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.
### Can I buy you a beer / coffee / random drink?
If you found this program useful and feel like giving back, feel free to send a donation [via PayPal](https://paypal.me/WernerRobitza).
## Related Tools and Articles
- [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/)
*(Have a link? Please propose an edit to this section via a pull request!)*
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://overtag.dk/"><img src="https://avatars.githubusercontent.com/u/374612?v=4?s=100" width="100px;" alt="Benjamin Balder Bach"/><br /><sub><b>Benjamin Balder Bach</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=benjaoming" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://chaos.social/@eleni"><img src="https://avatars.githubusercontent.com/u/511547?v=4?s=100" width="100px;" alt="Eleni Lixourioti"/><br /><sub><b>Eleni Lixourioti</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Geekfish" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/thenewguy"><img src="https://avatars.githubusercontent.com/u/77731?v=4?s=100" width="100px;" alt="thenewguy"/><br /><sub><b>thenewguy</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=thenewguy" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/aviolo"><img src="https://avatars.githubusercontent.com/u/560229?v=4?s=100" width="100px;" alt="Anthony Violo"/><br /><sub><b>Anthony Violo</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=aviolo" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://jacobs.af/"><img src="https://avatars.githubusercontent.com/u/952830?v=4?s=100" width="100px;" alt="Eric Jacobs"/><br /><sub><b>Eric Jacobs</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=jetpks" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kostalski"><img src="https://avatars.githubusercontent.com/u/34033008?v=4?s=100" width="100px;" alt="kostalski"/><br /><sub><b>kostalski</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=kostalski" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://justinppearson.com/"><img src="https://avatars.githubusercontent.com/u/8844823?v=4?s=100" width="100px;" alt="Justin Pearson"/><br /><sub><b>Justin Pearson</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=justinpearson" title="Code">π»</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Nottt"><img src="https://avatars.githubusercontent.com/u/13532436?v=4?s=100" width="100px;" alt="ad90xa0-aa"/><br /><sub><b>ad90xa0-aa</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Nottt" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Mathijsz"><img src="https://avatars.githubusercontent.com/u/1891187?v=4?s=100" width="100px;" alt="Mathijs"/><br /><sub><b>Mathijs</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=Mathijsz" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mpuels"><img src="https://avatars.githubusercontent.com/u/2924816?v=4?s=100" width="100px;" alt="Marc PΓΌls"/><br /><sub><b>Marc PΓΌls</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=mpuels" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.mvbattista.com/"><img src="https://avatars.githubusercontent.com/u/158287?v=4?s=100" width="100px;" alt="Michael V. Battista"/><br /><sub><b>Michael V. Battista</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=mvbattista" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://auto-editor.com"><img src="https://avatars.githubusercontent.com/u/57511737?v=4?s=100" width="100px;" alt="WyattBlue"/><br /><sub><b>WyattBlue</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=WyattBlue" title="Code">π»</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/g3n35i5"><img src="https://avatars.githubusercontent.com/u/17593457?v=4?s=100" width="100px;" alt="Jan-Frederik Schmidt"/><br /><sub><b>Jan-Frederik Schmidt</b></sub></a><br /><a href="https://github.com/slhck/ffmpeg-normalize/commits?author=g3n35i5" title="Code">π»</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="7">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## License
The MIT License (MIT)
Copyright (c) 2015-2022 Werner Robitza
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Changelog
## v1.26.6 (2023-03-16)
* Production status stable.
* Make install_requires more abstract.
## v1.26.5 (2023-03-15)
* Add "-hide_banner" remove "-nostdin" (#222)
The `-nostdin` option is unnessary because of the `-y` option.
Adding `-hide_banner` makes DEBUG statements shorter.
* Homebrew works on linux too.
* Explain ffmpeg installation steps.
## v1.26.4 (2023-02-08)
* Re-add requirements.txt to (maybe) fix conda-forge builds.
## v1.26.3 (2023-02-08)
* Fix requirements (#218)
* Improve types.
* Docs: add @g3n35i5 as a contributor.
## v1.26.2 (2023-02-06)
* Add ignore-revs file.
* Formatting and import sorting.
* Refactor: Improved logging behavior (#216)
* Add "apt update" (#215)
* Remove stalebot.
* Update README.
* Move to_ms and make CommandRunner more ergonomic (#212)
* Upgrade workflow, get ffmpeg from apt (#213)
* Turn FFmpegNormalizeError into a normal Exception (#211)
* Remove manifest.in (#210)
* Simplify logging (#209)
* Use pep585 type hints (#207)
* Don't use tempfile's private module function (#206)
* Fix smaller type errors.
* Reduce mypy errors 12 -> 4 (#204)
* Make input validation more efficient.
Make input validation more efficient
Re-separate formats and exts
## v1.26.1 (2022-12-18)
* Bump requirements.
* Add py.typed support.
* General refactoring + type hints (#202)
* Re-write to f-strings when possible (#201)
* Remove unnecessary utf-8 declarations (#200)
"-*- coding: utf-8 -*-" is a Python 2 construct and can be safely
removed. Other utf-8 declarations are also unnecessary.
## v1.26.0 (2022-12-14)
* Add .editorconfig.
* Link to API docs.
* Add docs.
* Add type hints, document everything, refactor some code.
* Add more audio formats (#199)
* Add python 3.11 to CI.
* Docs: add WyattBlue as a contributor for code (#198)
* docs: update README.md
* docs: update .all-contributorsrc
* Upgrade to Python 3.8 syntax (#197)
* Fix python version in github tests.
* Bump requirements to latest versions.
* Add python 3.11 to list of languages.
* Bump required python version to 3.8.
* Various minor code cleanups and type hints.
* Harmonize logger code.
* Update python version in tests.
* Docs: add @mvbattista as a contributor.
* Docs: add @mpuels as a contributor.
* Docs: add @Mathijsz as a contributor.
* Docs: add @Nottt as a contributor.
* Docs: add @justinpearson as a contributor.
* Docs: add @kostalski as a contributor.
* Docs: add @jetpks as a contributor.
* Docs: add @aviolo as a contributor.
* Docs: add @thenewguy as a contributor.
* Docs: add @Geekfish as a contributor.
* Docs: add @benjaoming as a contributor.
* Reference speechnorm.
## v1.25.3 (2022-11-09)
* Update README.
* Update list of pcm-incompatible extensions.
## v1.25.2 (2022-09-14)
* Constrain parsed ranges to avoid out of bounds, fixes #189.
* Fix readme for extra-input-options.
* Warn about dynamic mode only if not already set, fixes #187.
## v1.25.1 (2022-08-21)
* Add warning in case user specifies both --lrt and --keep-loudness-range-target.
## v1.25.0 (2022-08-20)
* Add option to keep loudness range target, fixes #181.
* Only show warning about disabling video if not yet disabled, addresses #184.
## v1.24.1 (2022-08-20)
* Code formatting.
* Extend warning for audio-only format to opus, fixes #184.
## v1.24.0 (2022-08-02)
* Update python requirements.
* Prevent race condition in output dir creation.
## v1.23.1 (2022-07-12)
* Increase possible loudness range target to 50.
## v1.23.0 (2022-05-01)
* Add way to force dynamic mode, clarify usage, fixes #176.
## v1.22.10 (2022-04-25)
* Add warning for cover art, addresses #174 and #175.
* Update README.
## v1.22.9 (2022-04-17)
* Improve issue templates.
* Do not print ffmpeg progress in debug logs.
* Remove unused import.
* Replace which() function with shlex version.
* Add python 3.10 in setup.py.
* Clarify minimum ffmpeg version.
## v1.22.8 (2022-03-07)
* Properly detect -inf dB input.
## v1.22.7 (2022-02-25)
* Debug command output for ffmpeg commands.
* Remove unneeded warning message.
## v1.22.6 (2022-02-20)
* Use astats instead of volumedetect filter, fixes #163.
Allows floating point calculation.
## v1.22.5 (2022-01-25)
* Print warning for bit depths > 16, addresses #163.
## v1.22.4 (2021-10-18)
* Re-raise error on ffmpeg command failure.
This prevents incorrectly telling the user that a normalized file was written when it wasn't.
## v1.22.3 (2021-08-31)
* Set tqdm lock for logging only when multiprocessing is available.
Multiprocessing is not available in all environments, for example
on AWS lambda python run time lacks /dev/shm, so trying to acquire
a multiprocessing Lock throws an OSError. The module could also be
missing in some cases (ex. Jython, although this library doesn't support
Jython anyway).
The solution to this is to only try to set the lock when multiprocessing
is available. The tqdm library solves this in the same manner.
For more details: https://github.com/slhck/ffmpeg-normalize/issues/156
* Add instructions on how to run tests.
## v1.22.2 (2021-08-14)
* Bump requirements, should fix #155.
* Move all examples to Wiki.
* Update badge link.
## v1.22.1 (2021-03-10)
* Add python_requires to setup.py.
## v1.22.0 (2021-03-09)
* Improve README.
* Add GitHub actions badge.
* Add GitHub actions tests.
* Properly convert EBU JSON values to float.
* Switch to f strings, remove Python 3.5 support.
* Format code with black.
* Fix flake8 errors.
* Factor out method.
* WIP: new tests.
* Log to stderr by default to enable JSON parsing.
* Remove release script.
## v1.21.2 (2021-03-06)
* Format setup.py.
* Switch progress to external lib.
* Remove support for older versions.
## v1.21.1 (2021-03-05)
* Adjusted handling of FFMPEG_PATH for binaries available via $PATH (#149)
* adjusted handling of FFMPEG_PATH for binaries available via $PATH
fixes #147
* adjusted use of %s to {} to match style
* documented the feature
* condensed error message as other lines are longer
## v1.21.0 (2021-02-27)
* Fix JSON output for multiple files.
* Update badge URL.
* Update README.md (#142)
* Update README.md
Added example of verifying levels
Fixes #141
* shorten example, add link to wiki page
* Error if no ffmpeg exec exists.
* Add stalebot.
## v1.20.2 (2020-11-06)
* Fixing stdin corruption caused by new subprocess (#138)
* Update issue template.
* Create FUNDING.yml.
* Fix usage, addresses #132.
## v1.20.1 (2020-07-22)
* Manually specify usage string, fixes #132.
* Fix local import for tests.
## v1.20.0 (2020-07-04)
* Add extra input options.
## v1.19.1 (2020-06-25)
* Add colorama to requirements, fixes #131.
* Fix warning that is printed with default options.
## v1.19.0 (2020-05-02)
* Fix issue with output folder, fixes #126.
* Fix typo in README's table of contents link to "File Input/Output". (#124)
* Clarify readme, fixes #122.
## v1.18.2 (2020-04-19)
* Add warning for automatic sample rate conversion, addresses #122.
* Ignore vscode folder.
* Fix printing of errors in conversion.
## v1.18.1 (2020-04-16)
* Fix unit tests.
* Improve handling of output file folder and errors.
* Clarify usage of output options, add warning.
* Improve documentation, fixes #120.
* Do not include bump messages in changelog.
## v1.18.0 (2020-04-13)
* Use measured offset in second pass, fixes #119.
* Update release instructions.
* Remove author names from changelog.
## v1.17.0 (2020-04-10)
* Update release script and changelog template.
* Apply pre-filters in all first passes, fixes #118.
This allows properly reading the level for any kind of normalization, even if
filters affect the loudness in the first pass.
## v1.16.0 (2020-04-07)
* Add all commits to changelog.
* Remove python 2 support.
* Add quiet option, fixes #116.
- Add a new quiet option
- Promote some warnings to actual errors that need to be shown
- Add a very basic test case
## v1.15.8 (2020-03-15)
* Improve release script.
* Python 3.8.
## v1.15.7 (2020-03-14)
* Only print length warning for non-EBU type normalization.
## v1.15.6 (2019-12-04)
* Remove build and dist folder on release.
* Do not exit on error in batch processing.
Simply process the next file if one has errors, addresses #110.
## v1.15.5 (2019-11-19)
* Use minimal dependency for tqdm.
* Remove specific python version requirement.
## v1.15.4 (2019-11-19)
* Freeze tqdm version.
* Update python to 3.7.
* Improve release documentation.
## v1.15.3 (2019-10-15)
* Do not print stream warning when there is only one stream.
* Remove previous dist versions before release.
## v1.15.2 (2019-07-12)
* Warn when duration cannot be read, fixes #105.
* Update README.
minor improvements in the description
## v1.15.1 (2019-06-17)
* Add output to unit test failures.
* Fix input label for audio stream.
## v1.15.0 (2019-06-17)
* Add pre-and post-filter hooks, fixes #67.
This allows users to specify filters to be run before or after the actual
normalization call, using regular ffmpeg syntax.
Only applies to audio.
* Document audiostream class.
* Warn when file is too short, fixes #87.
* Update release method to twine.
## v1.14.1 (2019-06-14)
* Handle progress output from ffmpeg, fixes #10.
* Merge pull request #99 from Nottt/patch-1.
fix -cn description
* Fix -cn description.
* Add nicer headers for options in README.
## v1.14.0 (2019-04-24)
* Add version file in release script before committing.
* Add option to keep original audio, fixes #83.
* Add pypi badge.
* Allow release script to add changelog for future version; upload to pypi.
## v1.13.11 (2019-04-16)
* Add release script.
* Add small developer guide on releasing.
* Move HISTORY.md to CHANGELOG.md.
* Fix ffmpeg static build download location.
## v1.3.10 (2019-02-22)
* Bump version.
* Cap measured input loudness, fixes #92.
## v1.3.9 (2019-01-10)
* Bump version.
* Fix handling of errors with tqdm.
* Improve readme.
* Delete issue template.
* Bump version.
* Clarify extra argument options, move to main entry point.
* Update issue templates.
## v1.3.8 (2018-11-28)
* Bump version.
* Clarify extra argument options, move to main entry point.
## v1.3.7 (2018-10-28)
* Bump version.
* Copy metadata from individual streams, fixes #86.
* Add python version for pyenv.
## v1.3.6 (2018-07-09)
* Bump version.
* Update README, fixes #79 and addresses #80.
## v1.3.5 (2018-06-12)
* Bump version.
* Minor README updates.
* Fix documentation of TMPDIR parameter.
## v1.3.4 (2018-05-05)
* Bump version.
* New way to specify extra options.
## v1.3.3 (2018-05-05)
* Update README.
* Decode strings in extra options.
## v1.3.2 (2018-04-25)
* Bump version.
* Merge pull request #69 from UbiCastTeam/master.
Stderror decoding ignoring utf8 encoding errors
* Stderror decoding ignoring utf8 encoding errors.
## v1.3.1 (2018-04-24)
* Bump version.
* Do not require main module in setup.py, fixes #68.
## v1.3.0 (2018-04-15)
* Bump version.
* Remove dead code.
* Fix for python2 division.
* Update documentation.
* Progress bar.
* Remove imports from test file.
* Fix travis file.
* WIP: progress bar.
* Minor typo in option group.
* Add simple unit test for disabling chapters.
## v1.2.3 (2018-04-11)
* Fix unit test.
* Bump version.
* Add option to disable chapters, fixes #65, also fix issue with metadata.
## v1.2.2 (2018-04-10)
* Bump version.
* Set default loudness target to -23, fixes #48.
## v1.2.1 (2018-04-04)
* Bump version.
* Merge pull request #64 from UbiCastTeam/encoding-issue.
Stdout and stderror decoding ignoring utf8 encoding errors
* Stdout and stderror decoding ignoring utf8 encoding errors.
## v1.2.0 (2018-03-22)
* Bump version.
* Add errors for impossible format combinations, fixes #60.
* Fix ordering of output maps, fixes #63.
* Improve documentation.
## v1.1.0 (2018-03-06)
* Add option to print first pass statistics.
## v1.0.10 (2018-03-04)
* Bump version.
* Restrict parsing to valid JSON part only, fixes #61.
* Add an example for MP3 encoding.
* Update paypal link.
## v1.0.9 (2018-02-08)
* Bump version.
* Add normalized folder to gitignore.
* Do not print escape sequences on Windows.
* Do not check for file existence, fixes #57.
* Add github issue template.
## v1.0.8 (2018-02-01)
* Bump version.
* Do not check for ffmpeg upon module import.
## v1.0.7 (2018-02-01)
* Bump version.
* Rename function test.
* Fix issue with wrong adjustment parameters, fixes #54.
## v1.0.6 (2018-01-30)
* Allow setting FFMPEG_PATH and document TMP.
## v1.0.5 (2018-01-26)
* Handle edge case for short input clips.
## v1.0.4 (2018-01-26)
* Bump version.
* Do not try to remove nonexisting file in case of error in command.
## v1.0.3 (2018-01-26)
* Bump version.
* Always streamcopy when detecting streams to avoid initializing encoder.
* Fix handling of temporary file.
* Add build status.
* Travis tests.
## v1.0.2 (2018-01-25)
* Fix bug with target level for peak/RMS.
* Update documentation formatting.
* Update history.
## v1.0.1 (2018-01-24)
* Bump version.
* Set default target to -23.
## v1.0.0 (2018-01-23)
* Add version info and test case for dry run.
* New feature detection, add documentation, contributors guide etc.
* WIP: v1.0 rewrite.
## v0.7.3 (2017-10-09)
* Use shutil.move instead of os.rename.
## v0.7.2 (2017-09-17)
* Allow setting threshold to 0.
## v0.7.1 (2017-09-14)
* Bump version.
* Update HISTORY.md.
* Merge pull request #37 from Mathijsz/fix-which-path-expansion.
expand tilde and environment variables, fixes #36
* Expand tilde and environment variables, fixes #36.
* Update HISTORY.md.
* Update README w.r.t. loudnorm filter.
* Update README and indentation.
## v0.7.0 (2017-08-02)
* Bump version.
* Fix handling of extra options with spaces.
* Include test script.
* Logging and other improvements.
* Add test files.
* Autopep8 that thing.
* Logger improvements.
* Add example for overwriting.
## v0.6.0 (2017-07-31)
* Allow overwriting input file, fixes #22.
* Version bump.
* Better handle cmd arguments.
* Update README.md.
add another example
## v0.5.1 (2017-04-04)
* Fix for problem introduced in 304e8df.
## v0.5 (2017-04-02)
* Fix pypi topics.
* Bump version and README.
* Fix issue where output was wrong format.
* Add EBU R128 filter.
* Use Markdown instead of RST for README/HISTORY.
* Define file encode for python3, fixes #24.
* Fix history.
* Fix option -np.
* Clarify merge option.
* Minor documentation improvements.
- change README from CRLF to LF
- add "attenuated" in description
- extend LICENSE year
- add license to main README
## v0.4.1 (2017-02-13)
* Update for release.
* Merge pull request #21 from mpuels/patch-1.
Fix for #13
* Fix for #13.
* Mention Python 3.
mention that Python 3 may work, just didn't have time to test
* Fix README's code blocks.
## v0.4 (2017-01-24)
* Code cleanup, add option to set format and audio codec.
## v0.3 (2017-01-19)
* Add option for no prefix, fixes #20.
* Handle multiple spaces in path; fixes issue #18.
* Handle spaces in path, fixes #12.
* Update README.rst.
* Change default level back to -26.
* Typo in README example.
* Update documentation.
* Bump to v0.2.0.
* Support for multiple files and output directories.
* Support merging of audio with input file
* Set audio codec and additional options
* User-definable threshold
* Better error handling and logging
* Deprecates avconv
* Change default level back to -28.
* Merge pull request #15 from auricgoldfinger/master.
Add extended normalisation options
* Add extended normalisation options.
- add program option to write output in a separate directory in stead of
prefixing it
- add program option to merge the normalized audio in the original
(video) file rather than creating a separate WAV file
- change the maximum setting: will now normalize so that max
volume is set to 0, adjusted with the given level.
e.g. : -m -l -5 will increase the audio level to max = -5.0dB
- improve verbose logging: number of files are written to the
info log
- improve performance: check first whether the output file
exists before calculating the volume levels + not modifying
the file if the adjustment < 0.5dB (level is never exactly 0)
* Update README, fixes #11.
## v0.1.3 (2015-12-15)
* Check for Windows .exe, fixes #10.
* Check path and fix #9.
* Merge pull request #8 from benjaoming/master.
Add MANIFEST.in
* Bump version.
* Add manifest to include missing files in sdist.
* Merge pull request #6 from jetpks/master.
Fixed ffmpeg v2.6.3 compatibility and docopt config
* Updated to work with ffmpeg v2.6.3, and fixed broken docopt config.
ffmpeg update:
ffmpeg v2.6.3 puts mean_volume on stderr instead of stdout, causing
`output` in `ffmpeg_get_mean` to be completely empty, and no match for
mean_volume or max_volume to be found.
Fixed by adding `stderr=subprocess.PIPE` in both Popen calls in
`run_command`, and combining stdout and stderr on return. We already
exit with non-zero return, so combining stderr/stdout shouldn't cause
any poor side-effects.
docopt config:
- args['--level'] was not recognizing its default because there was
an errant comma between -l and --level, and it needed <level> after
the arguments.
- Fixed spacing for --max
- Removed quotes around 'normalized' so single quote characters don't
end up in the output file names.
* Removed Windows carraige returns from __main__.py.
* Merge pull request #5 from mvbattista/master.
Installation update to ffmpeg
* Installation update to ffmpeg.
* Update to ffmpeg.
* Update HISTORY.rst.
* Update to ffmpeg.
* Merge pull request #4 from benjaoming/rename.
Rename project
* Make at least one file mandatory.
* Rename project and remove pyc file.
* Merge pull request #2 from benjaoming/docopt-setuptools-avconv.
Docopt, Setuptools, avconv compatibility
* Use docopt.
* Use normalize-audio when using avconv because it doesn't have a way to measure volume.
* Functional setup.py, communicate with avconv/ffmpeg about overwriting.
* Also detect avconv.
* Use a main function instead.
* Add a history for the project.
* Move to more unique module name.
* Update README.rst.
* Change the README to rst (PyPi)
* Delete .gitignore.
* Update README.md.
* Various improvements, fixes #1.
* License.
* Livense.
* Update README.md.
* Merge branch 'master' of https://github.com/slhck/audio-normalize.
* Initial commit.
* Initial commit.
%prep
%autosetup -n ffmpeg-normalize-1.26.6
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-ffmpeg-normalize -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 1.26.6-1
- Package Spec generated
|