[FFmpeg-user] Loudnorm filter changes bit depth

Marc mrc at frm01.net
Sat Mar 23 18:55:26 EET 2024


Hello everyone,


I'm using loudnorm with two passes on various FLAC music files.
By applying the filter, files will also change bit depth from 16 to 24 bit.

What is the reason for this change in bit depth? The documentation on 
loudnorm only mentions upsampling to 192 kHz when dynamic mode is used. 
(https://ffmpeg.org/ffmpeg-filters.html#loudnorm)
I'm certain I'm using linear scaling as all parameters necessary are 
specified and required criterea are also met. Linear scaling is also 
confirmed by ffmpeg when running the command.

Ideally I'd like to keep the original bit depth without manually 
specifying it for each file.


First pass:

`ffmpeg -i "Ad Infinitum - 02 Marching on Versailles.flac" -pass 1 
-filter:a loudnorm=print_format=json -f null /dev/null`

Output:

```
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
   built with gcc 13.2.1 (GCC) 20230801
   configuration: --prefix=/usr --disable-debug --disable-static 
--disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm 
--enable-lto --enable-fontconfig --enable-frei0r --enable-gmp 
--enable-gnutls --enable-gpl --enable-ladspa --enable-libaom 
--enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d 
--enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm 
--enable-libharfbuzz --enable-libiec61883 --enable-libjack 
--enable-libjxl --enable-libmodplug --enable-libmp3lame 
--enable-libopencore_amrnb --enable-libopencore_amrwb 
--enable-libopenjpeg --enable-libopenmpt --enable-libopus 
--enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg 
--enable-librubberband --enable-libsnappy --enable-libsoxr 
--enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 
--enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf 
--enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp 
--enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 
--enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc 
--enable-opencl --enable-opengl --enable-shared --enable-vapoursynth 
--enable-version3 --enable-vulkan
   libavutil      58. 29.100 / 58. 29.100
   libavcodec     60. 31.102 / 60. 31.102
   libavformat    60. 16.100 / 60. 16.100
   libavdevice    60.  3.100 / 60.  3.100
   libavfilter     9. 12.100 /  9. 12.100
   libswscale      7.  5.100 /  7.  5.100
   libswresample   4. 12.100 /  4. 12.100
   libpostproc    57.  3.100 / 57.  3.100
Input #0, flac, from 'Ad Infinitum - 02 Marching on Versailles.flac':
   Metadata:
     TITLE           : Marching on Versailles
     ARTIST          : Ad Infinitum
     DATE            : 2020-04-03
     ALBUM           : Chapter I - Monarchy
     track           : 2
     album_artist    : Ad Infinitum
     ISRC            : ATN261993602
     GENRE           : Rock;Power Metal;Heavy Metal
     PUBLISHER       : Napalm Records
     WWWAUDIOSOURCE  : 
https://adinfinitummusic.bandcamp.com/album/chapter-i-monarchy-2
     SOURCEMEDIA     : Bandcamp
   Duration: 00:03:50.92, start: 0.000000, bitrate: 1277 kb/s
   Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
   Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, 
bt470bg/unknown/unknown), 3000x3000, 90k tbr, 90k tbn (attached pic)
     Metadata:
       comment         : Cover (front)
Stream mapping:
   Stream #0:1 -> #0:0 (mjpeg (native) -> wrapped_avframe (native))
   Stream #0:0 -> #0:1 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
   Metadata:
     TITLE           : Marching on Versailles
     ARTIST          : Ad Infinitum
     DATE            : 2020-04-03
     ALBUM           : Chapter I - Monarchy
     track           : 2
     album_artist    : Ad Infinitum
     ISRC            : ATN261993602
     GENRE           : Rock;Power Metal;Heavy Metal
     PUBLISHER       : Napalm Records
     WWWAUDIOSOURCE  : 
https://adinfinitummusic.bandcamp.com/album/chapter-i-monarchy-2
     SOURCEMEDIA     : Bandcamp
     encoder         : Lavf60.16.100
   Stream #0:0: Video: wrapped_avframe, yuvj444p(pc, 
bt470bg/unknown/unknown, progressive), 3000x3000, q=2-31, 200 kb/s, 90k 
fps, 90k tbn (attached pic)
     Metadata:
       comment         : Cover (front)
       encoder         : Lavc60.31.102 wrapped_avframe
   Stream #0:1: Audio: pcm_s16le, 192000 Hz, stereo, s16, 6144 kb/s
     Metadata:
       encoder         : Lavc60.31.102 pcm_s16le
[out#0/null @ 0x5d755b580380] video:0kB audio:173190kB subtitle:0kB 
other streams:0kB global headers:0kB muxing overhead: unknown
frame=    1 fps=0.2 q=-0.0 Lsize=N/A time=00:03:48.10 bitrate=N/A 
speed=51.3x
[Parsed_loudnorm_0 @ 0x5d755b5aaa40]
{
     "input_i" : "-9.37",
     "input_tp" : "-0.24",
     "input_lra" : "5.00",
     "input_thresh" : "-19.62",
     "output_i" : "-23.22",
     "output_tp" : "-8.59",
     "output_lra" : "3.20",
     "output_thresh" : "-33.30",
     "normalization_type" : "dynamic",
     "target_offset" : "-0.78"
}
```


Second pass

`ffmpeg -i "Ad Infinitum - 02 Marching on Versailles.flac" -pass 2 
-filter:a 
loudnorm=measured_I=-9.37:measured_LRA=5.00:measured_tp=-0.24:measured_thresh=-19.62:print_format=json 
-c:a flac -y out.flac`

Output:

```
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
   built with gcc 13.2.1 (GCC) 20230801
   configuration: --prefix=/usr --disable-debug --disable-static 
--disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm 
--enable-lto --enable-fontconfig --enable-frei0r --enable-gmp 
--enable-gnutls --enable-gpl --enable-ladspa --enable-libaom 
--enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d 
--enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm 
--enable-libharfbuzz --enable-libiec61883 --enable-libjack 
--enable-libjxl --enable-libmodplug --enable-libmp3lame 
--enable-libopencore_amrnb --enable-libopencore_amrwb 
--enable-libopenjpeg --enable-libopenmpt --enable-libopus 
--enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg 
--enable-librubberband --enable-libsnappy --enable-libsoxr 
--enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 
--enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf 
--enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp 
--enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 
--enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc 
--enable-opencl --enable-opengl --enable-shared --enable-vapoursynth 
--enable-version3 --enable-vulkan
   libavutil      58. 29.100 / 58. 29.100
   libavcodec     60. 31.102 / 60. 31.102
   libavformat    60. 16.100 / 60. 16.100
   libavdevice    60.  3.100 / 60.  3.100
   libavfilter     9. 12.100 /  9. 12.100
   libswscale      7.  5.100 /  7.  5.100
   libswresample   4. 12.100 /  4. 12.100
   libpostproc    57.  3.100 / 57.  3.100
Input #0, flac, from 'Ad Infinitum - 02 Marching on Versailles.flac':
   Metadata:
     TITLE           : Marching on Versailles
     ARTIST          : Ad Infinitum
     DATE            : 2020-04-03
     ALBUM           : Chapter I - Monarchy
     track           : 2
     album_artist    : Ad Infinitum
     ISRC            : ATN261993602
     GENRE           : Rock;Power Metal;Heavy Metal
     PUBLISHER       : Napalm Records
     WWWAUDIOSOURCE  : 
https://adinfinitummusic.bandcamp.com/album/chapter-i-monarchy-2
     SOURCEMEDIA     : Bandcamp
   Duration: 00:03:50.92, start: 0.000000, bitrate: 1277 kb/s
   Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
   Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, 
bt470bg/unknown/unknown), 3000x3000, 90k tbr, 90k tbn (attached pic)
     Metadata:
       comment         : Cover (front)
Stream mapping:
   Stream #0:1 -> #0:0 (mjpeg (native) -> png (native))
   Stream #0:0 -> #0:1 (flac (native) -> flac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x5ee2dc47e1c0] deprecated pixel format used, make sure you 
did set range correctly
[swscaler @ 0x5ee2dc48ddc0] deprecated pixel format used, make sure you 
did set range correctly
[swscaler @ 0x5ee2dc48cc40] deprecated pixel format used, make sure you 
did set range correctly
     Last message repeated 1 times
[flac @ 0x5ee2dbc8a040] encoding as 24 bits-per-sample, more is 
considered experimental. Add -strict experimental if you want to encode 
more than 24 bits-per-sample
Output #0, flac, to 'out.flac':
   Metadata:
     TITLE           : Marching on Versailles
     ARTIST          : Ad Infinitum
     DATE            : 2020-04-03
     ALBUM           : Chapter I - Monarchy
     track           : 2
     album_artist    : Ad Infinitum
     ISRC            : ATN261993602
     GENRE           : Rock;Power Metal;Heavy Metal
     PUBLISHER       : Napalm Records
     WWWAUDIOSOURCE  : 
https://adinfinitummusic.bandcamp.com/album/chapter-i-monarchy-2
     SOURCEMEDIA     : Bandcamp
     encoder         : Lavf60.16.100
   Stream #0:0: Video: png, rgb24(pc, gbr/unknown/unknown, progressive), 
3000x3000, q=2-31, 200 kb/s, 90k fps, 90k tbn (attached pic)
     Metadata:
       comment         : Cover (front)
       encoder         : Lavc60.31.102 png
   Stream #0:1: Audio: flac, 44100 Hz, stereo, s32 (24 bit), 128 kb/s
     Metadata:
       encoder         : Lavc60.31.102 flac
[flac @ 0x5ee2dbc8fac0] Picture block too big 19237006 >= 16777216=   
0.0kbits/s speed= 228x
[out#0/flac @ 0x5ee2dbc5c380] video:18786kB audio:41876kB subtitle:0kB 
other streams:0kB global headers:0kB muxing overhead: unknown
frame=    1 fps=0.0 q=-0.0 Lsize=   41884kB time=00:03:50.92 
bitrate=1485.9kbits/s speed= 235x
[Parsed_loudnorm_0 @ 0x5ee2dcb1a4c0]
{
     "input_i" : "-9.33",
     "input_tp" : "-0.25",
     "input_lra" : "5.00",
     "input_thresh" : "-19.53",
     "output_i" : "-23.96",
     "output_tp" : "-14.88",
     "output_lra" : "5.00",
     "output_thresh" : "-34.14",
     "normalization_type" : "linear",
     "target_offset" : "-0.04"
}
```

Thanks a lot for your help



More information about the ffmpeg-user mailing list