/**
* 合并多个视频文件、mp3文件
*/
@Test
public void mergeFile(){
// 合并命令
String commit = "$0 -f concat -safe 0 -i $1 -c copy $2";
// ffmpeg
String ffmpegPath = "D:\\Java\\operSources\\ffmpeg-4.3.1\\bin\\ffmpeg.exe";
String str = commit.replace("$0", ffmpegPath).replace("$1", "D:\\jianpianDownload\\fileList.txt").replace("$2", "D:\\jianpianDownload\\合并后的文件.mp3");
System.out.println(str);
Runtime runtime = Runtime.getRuntime();
try {
Process proce = runtime.exec(str);
} catch (IOException e) {
e.printStackTrace();
}
}
fileList.txt里面的内容
file 'D:\jianpianDownload\中文慢摇-是不是我对你不够好.mp3'
file 'D:\jianpianDownload\中文慢摇-一起走过的日子.mp3'
合并后的文件