Saturday 10 February 2018

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


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



Answer



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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...