ffmpeg mix audio at specific time

橙三吉。 提交于 2019-12-12 13:25:50

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/32949824/ffmpeg-mix-audio-at-specific-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!