ffmpeg在不去除原声的情况下加上背景音乐

这篇博客介绍了如何使用FFmpeg在保持原声不变的情况下,将背景音乐与视频进行合并。提供了两条命令,第一条无原声合并,第二条则通过amix滤镜保留原声。关键参数包括inputs、duration和dropout_transition。作者建议参考FFmpeg官方文档,并提到了一位名为pjqdyd的网友的回答作为示例。
摘要由CSDN通过智能技术生成

1.无原声合并音视频 ffmpeg -i bgm.mp3 -i input.mp4 output.mp4

2.保留原声合并音视频 ffmpeg -i bgm.mp3 -i input.mp4 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 output.mp4

(注意:inputs=输入流数量, duration=决定流的结束,dropout_transition= 输入流结束时,容量重整时间, (longest最长输入时间,shortest最短,first第一个输入持续的时间)) 注意: 音频,视频输入流的命令顺序可能对视频合成有影响(猜测) (更多请查看ffmpeg官方文档) ps:我是看到这位pjqdyd 老哥的回答。

 示例JAVA代码如下~

public class MergeVideoMp3 {

	private String ffmpegEXE;
	
	public MergeVideoMp3(String ffmpegEXE) {
		super();
		this.ffmpegEXE = ffmpegEXE;
	}

	//ffmpeg -i bgm.mp3 -i input.mp4 -t 6 -filter_complex amix=inputs=2 output.mp4

	/**
	 * 注意:inputs=输入流数量, duration=决定流的结束,
	 * dropout_transition= 输入流结束时,容量重整时间,
	 * (longest最长输入时间,shortest最短,first第一个输入持续的时间))
	 * @throws Exception
	 */
	public void convertor(String videoInputPath, String mp3InputPath,
			double seconds, String videoOutput
ReadMe Release Version beta_1.0 index.py imageMatlab.py This is more or less a wrapper for Matplotlib imaging functions such that their behavior is equivalent, in terms of colormap, aspect and so forth, to the expected behavior of Matlab's functions. sepVocal.py This script can be used to execute the desired separation. See below for an example of use of this file. SIMM.py This script implements the actual algorithm for parameter estimation. It is mainly used by sepVocal.py. tracking.py The Viterbi decoding algorithm is implemented in this script. Requirements: These scripts have been tested with Python 2.7, The packages that are required to run the scripts are pydub,ffmepg, Numpy, Spicy, Matplotlib. One can respectively find the latest versions at the following addresses: http://pydub.com/ https://ffmpeg.org http://numpy.org/ http://scipy.org/ http://matplotlib.sourceforge.net/ Notes: Prefer recent versions of the above packages, in order to avoid compatibility issues, notably for Matplotlib. Note that this latter package is not necessary for the program to run, although you might want to watch a bit what is happening! Spicy should be version 0.8+, since we use its io.wavefile module to read the wave files. We once used the audio lab module, but it would seem that it is a bit more complicated to install (with the benefit that many more file formats are allowed). Usage: The easy way to use these scripts is to run the exec package of our release version: http://www.github.com/beata_1.0 for more develop: you can run the index.py on pycharm directly. note: the output files will create under you source wav file. ContactMe Email:xlzhang14@fudan.edu.cn
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值