如何使用ffmpeg重叠和合并多个音频文件? [英] How to overlap and merge multiple audio files using ffmpeg?
问题描述
我正在尝试将多个音频文件合并到一个文件中,而不是使用以下命令将其合并:
I am trying to merge multiple audio files into a single file but instead of concatenating which I can do using the following command:
ffmpeg -v debug -i file1.wav -i file2.wav -i file3.wav -filter_complex [0:0]concat=n=3:v=0:a=1[out] -map [out] output.wav
尽管此命令可以很好地进行串联,但是我想重叠一下,例如第一个文件末尾的最后100ms和下一个文件开始的100ms.
Though this command works fine for concatenating, I want to overlap let's say the last 100ms of the end of the first file and 100ms of the start of the next file.
我现在正在尝试使用ffmpeg提供的'acrossfade'过滤器,但是我没有成功.
I am now trying to use 'acrossfade' filter that ffmpeg provides but I am not having any success with it.
ffmpeg -v debug -i file1.wav -i file2.wav -i file3.wav -filter_complex [0:a]acrossfade=d=0.100:c1=exp:c2=exp,[1:a]acrossfade=d=0.100:c1=exp:c2=exp,[2:a]acrossfade=d=0.100:c1=exp:c2=exp
这是我到目前为止提出的内容,但是由于它抛出"对于frame_length = 1的缓冲区太短(n = 0)"而无法正常工作.
This is what I have come up till now, but does not work as it throws 'Buffer is too short (n=0) for frame_length=1' error.
文档不是很有帮助,有人知道该怎么做吗?
The documentation is not very helpful, does anyone have any idea what can be done?
提前谢谢!
推荐答案
acrossfade旨在在两个输入之间创建过渡.因此,每对输入都必须应用交叉淡入淡出功能,并将结果用作下一个交叉淡入淡出的输入.
acrossfade is meant to create a transition between two inputs. So, each pair of inputs has to have acrossfade applied with the result being used as an input for the next acrossfade.
ffmpeg -v debug -i file1.wav -i file2.wav -i file3.wav -filter_complex "[0:a][1:a]acrossfade=d=0.100:c1=exp:c2=exp[a01];[a01][2:a]acrossfade=d=0.100:c1=exp:c2=exp" out.wav
编辑:您的输入为16000 Hz,淡入淡出持续时间为0.1s(!),以输入采样率小于2个音频帧.默认帧大小为1024个样本.因此,需要减小框架尺寸.
Edit: your inputs are 16000 Hz, and your crossfade duration is 0.1s (!), which is less than 2 audio frames at the input sampling rate. Default frame size is 1024 samples. So, frame size needs to be lowered.
ffmpeg -v debug -i file1.wav -i file2.wav -i file3.wav -filter_complex "[0:a]asetnsamples=256[0a];[1:a]asetnsamples=256[1a];[2:a]asetnsamples=256[2a];[0a][1a]acrossfade=d=0.100:c1=exp:c2=exp[a01];[a01][2a]acrossfade=d=0.100:c1=exp:c2=exp" out.wav
这篇关于如何使用ffmpeg重叠和合并多个音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!