1

I am trying to use ffmpeg to merge two audios, in.mp3 and out.mp3, like this:

ffmpeg -i in.mp3 -i out.mp3 -filter_complex amix=inputs=2:duration=longest -c:a libmp3lame res.mp3

But the final output res.mp3 has different volume levels.

When I run ffmpeg 'volumedetect' it gives these outputs:

1. For in.mp3

ffmpeg -i in.mp3 -af "volumedetect" -vn -sn -dn -f null NUL

Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s

size=N/A time=00:02:07.17 bitrate=N/A speed= 344x

[Parsed_volumedetect_0 @ 00554a00] mean_volume: -22.3 dB

[Parsed_volumedetect_0 @ 00554a00] max_volume: -0.3 dB


2. For out.mp3

ffmpeg -i out.mp3 -af "volumedetect" -vn -sn -dn -f null NUL

Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s

size=N/A time=00:02:07.17 bitrate=N/A speed= 434x

[Parsed_volumedetect_0 @ 00441100] mean_volume: -22.5 dB

[Parsed_volumedetect_0 @ 00441100] max_volume: -3.5 dB


Given the differences in Hz, speed, mean/max volumes - what is the right way to normalize the two audios before merging them with amix?

THANKS!

1
  • I used this and it worked: ffmpeg -i in.mp3 -i out.mp3 -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" -c:a libmp3lame res.mp3
    – ILPuser
    May 22 at 18:03
0

One way to make the volume levels consistent is:

ffmpeg -i in.mp3 -i out.mp3 -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" -c:a libmp3lame res.mp3

But this may not be the best way. Please let me know if there are better ways, and what are the pros and cons of the above method. thanks.

Your Answer

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

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