如何连接一个 wav 文件列表?

How to concatenate a list of wav files?

我在 file.txt

中有一个 wav 文件列表
1.wav
2.wav
...

我使用下面的命令来执行操作。

ffmpeg -f concat -safe 0 -i file.txt -c copy output.wav

不过我得到

[concat @ 0x5574a8046900] Line 1: unknown keyword 1.wav: Invalid data found when processing input

为什么这不起作用?

如果你的 .wav 文件不包含空格等特殊字符,你可以这样做:

files=(1.wav 2.wav ...)

ffmpeg -f concat -safe 0 ${files[@]/#/-i } -c copy output.wav

Based on this wiki page,你需要修改你的file.txt如下:

file '1.wav'
file '2.wav'
# ... etc

命令本身应该可以正常工作。

页面摘录:

... This demuxer reads a list of files and other directives from a text file and demuxes them one after the other, as if all their packets had been muxed together. ...

Instructions

Create a file mylist.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored):

# this is a comment
file '/path/to/file1.wav'
file '/path/to/file2.wav'
file '/path/to/file3.wav'