使用ffmpeg AVfilter 中的amix实现混音

官方文档:
6.16 amix
Mixes multiple audio inputs into a single output.

Note that this filter only supports float samples (the amerge and pan audio filters support many formats). If the amix input has integer samples then aresample will be automatically inserted to perform the conversion to float samples.

译:将多个音频输入混合为单个输出。
请注意,此过滤器仅支持浮点型(amerge和pan音频过滤器支持多种格式)。 如果amix输入具有整数样本,那么将自动插入 aresample以执行向浮点样本的转换。

For example

ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT

will mix 3 input audio streams to a single output with the same duration as the first input and a dropout transition time of 3 seconds.

It accepts the following parameters:
参数:

inputs
The number of inputs. If unspecified, it defaults to 2.//输入的数量,如果没有指明,默认为2.

duration
How to determine the end-of-stream.//决定了流的结束

longest
The duration of the longest input. (default)//最长输入的持续时间

shortest
The duration of the shortest input.//最短输入的持续时间

first
The duration of the first input.//第一个输入的持续时间

dropout_transition
The transition time, in seconds, for volume renormalization when an input stream ends. The default value is 2 seconds.
//输入流结束时(音频)容量重整化的转换时间(以秒为单位)。 默认值为2秒。

使用ffmpeg实现合并多个音频为一个音频的方法

可以使用ffmpeg的filter功能来进行这个操作,而且效果很好

amerge也可以实现,但是这里就介绍一下使用amix来做的方法
ffmpeg的filter功能强大的功能能够满足几乎所有的音视频操作,包括合并音频
ffmpeg可以支持多输入通道,也可以支持多输出通道,合并多音频的功能就使用多输入通道,单输出通道,所以大概的形式如下:

ffmpeg -i INPUT -i INPUT -i INPUT output

如果想用amix,这个参数是-filter_complex中的参数,可以这么用:

-filter_complex amix=inputs=2:duration=first:dropout_transition=2

整条合并多音频的的命令行即如下

ffmpeg -i take.mp3 -i pingfan.mp3 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 outputnew2.mp3

上面的命令为将平凡之路与take me to your heart合并成一个a.mp3文件,整个过程如下:


屏幕快照.png

(后文参考:http://blog.chinaunix.net/uid-11344913-id-3934279.html)



作者:WSGNSLog
链接:http://www.jianshu.com/p/c96992485715
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值