ffmpeg在特定时间混合音频 [英] ffmpeg mix audio at specific time

查看:1234
本文介绍了ffmpeg在特定时间混合音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将2个音频文件混合在一起-一个文件的长度为2分钟,另一个文件为10秒.我希望将两个文件混合在一起,以便仍然可以听到两种声音.我希望这个10秒的剪辑在30秒内准确到达10秒,以便在40秒后结束.

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.

我知道如何使用ffmpeg将2个音频文件混合在一起

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

但是,我不知道如何在特定时间开始播放这10秒的声音.

However, I do not know how to start this 10 second sound at a specific time.

推荐答案

自此发布以来,我已经找到了解决此问题的方法-我想与其他人共享它,因为我花了很多时间在寻找它.

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>

从这里开始,您需要在需要的时候将10秒的片段添加到空白音频文件中.

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>

这篇关于ffmpeg在特定时间混合音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆