I want to mix 2 audio files together - one file has a length of 2 mins and the other is a 10 second sound. I want both files to mix so both sounds can still be heard. I want this 10 second clip to come in exactly at 30 seconds for the 10 seconds so it will end at 40 seconds.
I know how to mix 2 audio files together using ffmpeg
ffmpeg -i input.mp3 -i input2.mp3 -filter_complex amerge -c:a libmp3lame -q:a 4 output.mp3
However, I do not know how to start this 10 second sound at a specific time.
The itsoffset option applies to all streams embedded within the input file. Therefore, adjusting timestamps only for a single stream requires to specify twice the same input file. adjusts timestamps of the input audio stream(s) only.
since posting this i have found a solution to this problem - i want to share it for other people to use as i spent a lot of time looking for this.
create a blank audio file longer than the longest clip.
ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t <seconds> -q:a 9 -acodec libmp3lame <blank audio>
from here then you need to add the 10 second clip at the time you want to the blank audio file.
ffmpeg -i <blank audio> -i < audio file 2> -filter_complex "aevalsrc=0:d= <time> [s1];[s1][1:a]concat=n=2:v=0:a=1[aout]" -c:v copy -map 0:v -map [aout] <output file>
from here then you overlay this now longest clip to the original longer clip
ffmpeg -i <output from silent and short clip> -i <original long clip> -filter_complex "amix=inputs=2:duration=longest:dropout_transition=0, volume=2" <output audio file>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With