3

I have lossless video captures of videotapes, some of which unfortunately have their output volume limited by both the camcorder's lack of a volume slider for anything other than the built-in speaker and the Dazzle DVC100 USB video capture device's lack of volume settings (and mysterious inability to materialise in the Windows audio mixer or recording devices panel despite VirtualDub2 detecting and recording from it just fine).

Initially, I had been using this to normalize the audio.

-af loudnorm=I=-16:LRA=11:TP=-1.5

However, upon further reading of the FFmpeg documentation and the Wikipedia article on audio normalisation, I realise that "loudness normalisation" is different from "peak normalisation". Since ffmpeg's loudnorm function named just that, I need to be sure that what I'm doing is exactly what I want.

I merely want to increase the volume as much as possible without clipping and without losing any dynamic range or averaging the volume levels across the entire recording. Is this possible in ffmpeg? I've searched quite a bit and loudnorm seems to be so popular as to drown out anything else normalisation related.

1 Answer 1

3

You can run the volumedetect filter first to identify peak volume. Then run volume filter in a 2nd pass to add a uniform gain.

Pass 1

ffmpeg -i input -af volumedetect -vn -f null -

Output:

[Parsed_volumedetect_0 @ 0000022356a12940] n_samples: 495350
[Parsed_volumedetect_0 @ 0000022356a12940] mean_volume: -28.9 dB
[Parsed_volumedetect_0 @ 0000022356a12940] max_volume: -4.2 dB
[Parsed_volumedetect_0 @ 0000022356a12940] histogram_4db: 26
[Parsed_volumedetect_0 @ 0000022356a12940] histogram_5db: 107
[Parsed_volumedetect_0 @ 0000022356a12940] histogram_6db: 182
[Parsed_volumedetect_0 @ 0000022356a12940] histogram_7db: 153
[Parsed_volumedetect_0 @ 0000022356a12940] histogram_8db: 158

The max volume is your peak.

Pass 2

ffmpeg -i input -af volume=+4.2dB -c:v copy output
5
  • 1
    Is there a way to do this in one pass? My goal is to tie this into a simple batch file, but a two pass solution complicates things a bit. Commented Jan 3, 2022 at 7:22
  • The adjustment value can only be ascertained after the peak has been identified. In order to identify the peak, the entire input has to be scanned first.
    – Gyan
    Commented Jan 3, 2022 at 12:03
  • 1
    Do you know what the best way to grab the value of max volume and use that as a variable in a batch or bash script? I don't want to do this manually, but I'm paranoid about setting variables from output because I'm not confident in consistently getting the correct value for the variable. Commented Jan 4, 2022 at 1:36
  • 4
    ffmpeg -hide_banner -i "input" -af volumedetect -vn -f null - 2>&1 | grep -oP "(?<=max_volume:\s-)[^dB]+" will print 4.2 in the answer sample.
    – Gyan
    Commented Jan 4, 2022 at 5:12
  • 3
    Capture it in bash like VOL=$(command)
    – Gyan
    Commented Jan 4, 2022 at 5:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .