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.
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
:
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 givedynaudnorm
a peak value for volume to get desired output instead of matching the volume with peak point?"dynaudnorm=p=0.5"
or"dynaudnorm=r=0.6"