2

I have a script to process/encode videos. Some of the videos have varying audio levels (like 2 videos were merged and one had loud audio and other quiet audio). I want to normalize the audio in a way that loud audio is reduced and quiet audio is increased to make them both almost equal. Although I am using HandbrakeCLI for encoding but any other solution like ffmpeg which can be used from Linux terminal will work.

I have done some R&D but I have very limited knowledge about audio so I could not make it work. Some of the solutions I have been looking into are audio-normalize and Replaygain (Just a tag but I need to directly change the video when encoding not just add a tag).

I have a sample input and a sample output. Sample output is created by manually selecting loud audio and decreasing it and manually selecting quiet audio and increasing it.

Input: Original Audio

Output: Normalized Audio

As you can see in the original audio, whole audio is quiet except last small part which is too loud and in the output both are almost equal. But the problem is I want to do it automatically.

Edit:

Result of ffmpeg -i in.mp4 -af "dynaudnorm" -vcodec copy out.mp4: After dynaudnorm

4
  • 1
    Look into the dynaudnorm filter.
    – Gyan
    Feb 8, 2016 at 11:41
  • @Mulvya Thanks, seems to be possible solution for my problem according to introductory paragraph. Will update after trying it. Feb 8, 2016 at 11:44
  • @Mulvya please see my edit. dynaudnorm maximizes the volume to match highest volume, but there are some issues like, in the start volume is still quiet, also is there a way to give dynaudnorm a peak value for volume to get desired output instead of matching the volume with peak point? Feb 8, 2016 at 12:49
  • Experiment with the peak and rms parameters e.g. "dynaudnorm=p=0.5" or "dynaudnorm=r=0.6"
    – Gyan
    Feb 8, 2016 at 14:51

1 Answer 1

0

There is also the vlevel effect and accompanying vlevel-bin program. It uses a look-ahead buffer to see if the sound coming up is quieter or louder than a set threshold, and begins to shift the volume to accommodate what is going to happen soon.

Pros: it doesn't need configuring. Given just an audio file it will set them to a consistent level, so if every video is processed with vlevel they will be normalized to one another.

Cons: it is not a built-in ffmpeg effect; you will have to extract the sound from a video, convert it to the correct bitrate and format for vlevel-bin, then re-encode the sound back in to your video. It will also (necessarily) crush the dynamic range of your audio. Not to the extremes of the loudness wars, but the peaks and valleys will be noticably quashed.

I used to use this on a handful of television shows which relied on constant explosions between quiet conversation methods, and it made them watchable without having a volume control on hand for the entire episode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.