ffmpeg:如何在单个命令中合并音频文件并添加背景音乐? [英] ffmpeg: How to concat audio files and add background music in a single command?

查看:603
本文介绍了ffmpeg:如何在单个命令中合并音频文件并添加背景音乐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要在单个命令中合并音频文件并添加背景音乐.

Need to concat audio files and add background music in a single command.

现在我使用以下命令,

要进行合并:

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4 -i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4 -filter_complex '[0:0][1:0]concat=n=10:v=0:a=1[out]' -map '[out]' -strict -2 -y 10_final.mp4

添加背景音乐:

ffmpeg -i 10_final.mp4 -i music.mp4 -filter_complex "[0:a]volume=1dB[a0];[1:a]volume=0.5[a1];[a0][a1]amerge=inputs=2[a]" -map "[a]" -ac 1 -ab 32000 -ar 22050 -strict -2 -y 10_with_music.mp4

但是他的过程非常耗时,因为每次对输出进行文件读/写时都会发生.

But his process is a quite time-consuming process as every time the file read/write happening to the output.

有没有一种方法可以将上述两个命令合并为一个,以便对命令进行优化.

Is there a way I can merge these two above commands to a single so that the command should be optimized.

推荐答案

使用

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4
       -i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4
       -i music.mp4
       -filter_complex '[0:0][1:0]...[9:0]concat=n=10:v=0:a=1,volume=1dB[a0];
                        [10]volume=0.5dB[a1];[a0][a1]amerge[a]'
       -map '[a]' -strict -2 -y 10_with_music.mp4

这篇关于ffmpeg:如何在单个命令中合并音频文件并添加背景音乐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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