ffmpeg : combine two or three audios into one by lowering the volume of the other

2

Want to combine some audio files eg:

1) one long audio file which will act as a background audio 2) some audio files which will be replaced at specific intervals like at 10 sec of the first one

So final output required is audio-1 60 sec audio-2 starting from 10 sec to 20 sec with audio-1 at 0.1 volume

somya bhargava

Posted 2016-06-16T02:52:28.730

Reputation: 49

Answers

2

For the scenario mentioned in the question, use

ffmpeg -i audio1 -i audio2 -filter_complex \
        "[0]atrim=0:10[s1];
         [0]atrim=10:20,asetpts=N/SR/TB,volume=0.1[s2];
         [0]atrim=20,asetpts=N/SR/TB[s3];
         [1]atrim=duration=10,adelay=10000|10000[v2];
         [s1][s2][s3]concat=n=3:v=0:a=1[b];
         [b][v2]amix[a]"
       -map [a] mixed.mp3

Usually, you'd want to use the sidechaincompress filter to adaptively reduce the volume of the music stream by analyzing the volume of the foreground audio.

Gyan

Posted 2016-06-16T02:52:28.730

Reputation: 21 016

Is there a way to detect if the other sound is silence (use silencedetect) and then only change the volume – somya bhargava – 2016-06-16T06:25:00.453

That's what sidechaincompress does: changes volume of one stream according to the volume of another reference stream. – Gyan – 2016-06-16T06:47:53.723