Opened 7 years ago

Closed 7 years ago

#6570 closed enhancement (fixed)

Warn that loudnorm filter resamples to 192 kHz

Reported by: slhck Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: loudnorm
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The loudnorm filter changes the sample rate of the input output stream, sometimes doubling it, sometimes it will be even higher.

The desired behavior would be that the sample rate remains the same.

./ffmpeg -f lavfi -i anullsrc=r=48000 -filter:a loudnorm -t 1 out.wav
ffmpeg version N-86910-g797c232-tessus Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-libzvbi --enable-version3 --disable-ffplay --disable-indev=qtkit
  libavutil      55. 69.100 / 55. 69.100
  libavcodec     57.102.100 / 57.102.100
  libavformat    57. 76.100 / 57. 76.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 95.100 /  6. 95.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, lavfi, from 'anullsrc=r=48000':
  Duration: N/A, start: 0.000000, bitrate: 768 kb/s
    Stream #0:0: Audio: pcm_u8, 48000 Hz, stereo, u8, 768 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_u8 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'out.wav':
  Metadata:
    ISFT            : Lavf57.76.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 192000 Hz, stereo, s16, 6144 kb/s
    Metadata:
      encoder         : Lavc57.102.100 pcm_s16le
size=     750kB time=00:00:01.00 bitrate=6144.8kbits/s speed=6.65x
video:0kB audio:750kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.013281%
./ffmpeg -f lavfi -i anullsrc=r=44100 -filter:a loudnorm -t 1 -c:a aac out.m4a
ffmpeg version N-86910-g797c232-tessus Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-libzvbi --enable-version3 --disable-ffplay --disable-indev=qtkit
  libavutil      55. 69.100 / 55. 69.100
  libavcodec     57.102.100 / 57.102.100
  libavformat    57. 76.100 / 57. 76.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 95.100 /  6. 95.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, lavfi, from 'anullsrc=r=44100':
  Duration: N/A, start: 0.000000, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_u8 (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, ipod, to 'out.m4a':
  Metadata:
    encoder         : Lavf57.76.100
    Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 96000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.102.100 aac
size=       2kB time=00:00:01.00 bitrate=  13.7kbits/s speed=6.96x
video:0kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 192.006805%
[aac @ 0x7f8452003600] Qavg: 65030.441

This has also been observed by a user here: https://superuser.com/questions/1218471/

Change History (5)

comment:1 by Kyle Swanson, 7 years ago

Resolution: invalid
Status: newclosed

for true peak limiting, this filter upsamples to 192 kHz. It is up to you to downsample to an appropriate sampling rate. The rationale for this is that one may not want the same sample rate on their output stream. (why resample, resample, and then resample again?)

http://k.ylo.ph/2016/04/04/loudnorm.html

comment:2 by slhck, 7 years ago

Okay, I understand now, thanks. Of course it makes sense to avoid unnecessary resampling. But seeing that multiple users are confused by this, and that it leads to unplayable files, there should be at least a sentence in the documentation saying:

“To accurately detect true peaks, the audio stream will be upsampled to 192 kHz.”

One might even consider printing a warning, since no other filter that I know of will adjust the sample format or stream properties without explcitly informing the user (e.g., frame rate, pixel size, …):

“Warning: Audio sample rate was automatically changed to 192 kHz.”

comment:3 by llogan, 7 years ago

Resolution: invalid
Status: closedreopened
Summary: loudnorm filter changes sample rateWarn that loudnorm filter resamples to 192 kHz
Type: defectenhancement

Reopening as an enhancement request. Feel free to submit a patch for the docs and/or to provide a warning.

comment:4 by slhck, 7 years ago

Patch for the documentation submitted.

Having thought about it a little more, I don't think a warning message will be appropriate, as this is normal and expected behavior of the filter. In addition, for example, warning messages for auto-selection of yuv444p for libx264 have also been removed recently.

comment:5 by llogan, 7 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.