Ali Akram Ali Akram - 2 months ago 15
Linux Question

Adjust volume of both input mp3 files while merging using ffmpeg

I am using the following command to merge two audio files (mp3) into one output.mp3

-i /sdcard/NNR/input1.mp3 -i /sdcard/NNR/input2.mp3
-filter_complex amerge -ac 2 -c:a libmp3lame
-q:a 4 /sdcard/NNR/output.mp3


Kindly suggest me how to adjust volume level of both input files to some specific level.

I have found the following filter variable but don't exactly know how to adjust into my command.

ffmpeg -i a.mp3 -i b.mp3
-filter_complex "[0:a]volume=.25[A];[1:a][A]amerge[out]"
-map [out] -c:a pcm_s16le out.wav


Any help will be much appreciated.Thanks

Answer

You would use

-i /sdcard/NNR/input1.mp3 -i /sdcard/NNR/input2.mp3
-filter_complex "[0]volume=0.5,pan=2c[a];[1]volume=0.7,pan=2c[b];[a][b]amix=duration=shortest"
-ac 2 -c:a libmp3lame -q:a 4 /sdcard/NNR/output.mp3