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.


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

  • Look into the dynaudnorm filter. – Gyan Feb 8 '16 at 11:41
  • @Mulvya Thanks, seems to be possible solution for my problem according to introductory paragraph. Will update after trying it. – Muhammad Tahir Feb 8 '16 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? – Muhammad Tahir Feb 8 '16 at 12:49
  • Experiment with the peak and rms parameters e.g. "dynaudnorm=p=0.5" or "dynaudnorm=r=0.6" – Gyan Feb 8 '16 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.