gpt4 book ai didi

ffmpeg - 如何在特定时间添加多个音频文件,使用 ffmpeg 在静音音频文件上?

转载 作者:行者123 更新时间:2023-12-04 22:55:02 27 4
gpt4 key购买 nike

我需要在特定时间覆盖现有的静音.mp3 上的音频文件。像这样的东西:

[----[...audio1...]----------[...audio2...]---------------]

我尝试了以下方法,但它不起作用:
ffmpeg -y -i silence.mp3 -itsoffset 4 -i audio1.mp3 -itsoffset 30 -i audio2.mp3 -c:a copy final.mp3

任何帮助都将不胜感激。谢谢你。

最佳答案

有几种方法。

阿德莱,混合

使用 adelayamix过滤器:

ffmpeg -i audio1.mp3 -i audio2.mp3 -filter_complex "[0]adelay=4s:all=1[0a];[1]adelay=30s:all=1[1a];[0a][1a]amix=inputs=2[a]" -map "[a]" output.mp3

注意 amix 过滤器会降低输出的音量以防止削波。如果需要,可以使用 dynaudnorm 或音量过滤器。

延迟,连接过滤器

或者adelay和 concat过滤器。这假设 audio1.mp4为 10 秒长,两个输入具有相同的采样率和 channel 布局:
ffmpeg -i audio1.mp3 -i audio2.mp3 -filter_complex "[0]adelay=4s:all=1[0a];[1]adelay=16s:all=1[1a];[0a][1a]concat=n=2:v=0:a=1[a]" -map "[a]" output.mp3

anullsrc,连接解复用器

或者使用 anullsrc filter 生成静默文件作为分隔符:
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 4 4.mp3
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 16 16.mp3

创建 input.txt:
file '4.mp3'
file 'audio1.mp3'
file '16.mp3'
file 'audio2.mp3'

然后使用 concat demuxer :
ffmpeg -f concat -i input.txt -c copy output.mp3

关于ffmpeg - 如何在特定时间添加多个音频文件,使用 ffmpeg 在静音音频文件上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60027460/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com