Join 2 mp3 files with one having lower volume than other

1

I have 2 mp3 files (a.mp3 and b.mp3) and I want to overlap them using ffmpeg. How to overlap them in such a way that a.mp3's volume is low and b.mp3 volume is high so that it appears that a.mp3 is running in background of b.mp3?

Utkarsh Srivastav

Posted 2015-05-27T04:48:20.950

Reputation: 111

How about using http://sourceforge.net/projects/audacity/ (or any other sound editing tool)? Are you trying to automate the task?

– Scott Rhee – 2015-05-27T05:08:46.743

Please show the complete console output of ffmpeg -i a.mp3 -i b.mp3. The info will be useful for providing an answer. – llogan – 2015-05-27T05:11:45.257

Answers

0

You can change the volume of audio streams using the volume filter. However, you will have to re-encode the audio when you use a filter. If you don't want to lose quality, you can always re-encode to an uncompressed format (using -c:a pcm_s16le, but then your file sizes will be larger. Alternatively, you can compress the file further and leave it in the mp3 format - but naturally the quality will be reduced...

Also, you'll probably want to play around with how loud you want each stream, but here is an example that takes your a.mp3 file and makes it 25% of it's original volume while leaving b.mp3's volume alone. In this example we are going the uncompressed audio route and going into a .wav container.

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

occvtech

Posted 2015-05-27T04:48:20.950

Reputation: 980

1Just noting that if the inputs are stereo this will create a 4-channel output (one reason why I asked for the console output). Adding -ac 2 will make it a stereo output if desired. – llogan – 2015-05-27T21:04:03.117