加入多个 MP3 文件(无损)

osh*_*nen 6 linux mp3 debian ubuntu

如何将多个 MP3 文件合并为一个?“cat”和“mp3wrap”不好,因为它们产生非标准的 MP3 文件。我知道我可以使用 audacity,但是当您将 1000 个 MP3 文件合并为一个时,这需要很长时间。

有什么建议?

evi*_*oup 13

您可以使用ffmpegconcat demuxer以编程方式执行此操作。

首先,创建一个名为 input.txt 的文件,其中包含类似的行

file '/path/to/input1.mp3'
file '/path/to/input2.mp3'
file '/path/to/input3.mp3'
Run Code Online (Sandbox Code Playgroud)

...等等。然后,运行以下 ffmpeg 命令:

ffmpeg -f concat -i inputs.txt -c copy output.mp3
Run Code Online (Sandbox Code Playgroud)

可以使用 bash for循环轻松生成 input.txt (这也可以使用 Windows 批处理 for 循环完成),假设您想按字母顺序合并文件。这将匹配工作目录中的每个*.mp3,但可以轻松修改:

for f in ./*.mp3; do echo "file '$f'" >> inputs.txt; done
##  Alternatively
printf "file '%s'\n" ./*.mp3 >> inputs.txt
Run Code Online (Sandbox Code Playgroud)

也可以在一行中完成整个事情,避免使用进程替换创建中间列表文件:

ffmpeg -f concat -i <(printf "file '%s'\n" ./*.mp3) -c copy output.mp3
Run Code Online (Sandbox Code Playgroud)


Nif*_*fle 7

使用ffmpeg或类似工具将所有 MP3 转换为一致的格式,例如

ffmpeg -i originalA.mp3 -f mp3 -ab 128kb -ar 44100 -ac 2 intermediateA.mp3 ffmpeg -i originalB.mp3 -f mp3 -ab 128kb -ar 44100 -ac 2 intermediateB.mp3

然后,在运行时,将您的文件连接在一起:

cat intermediateA.mp3 intermediateB.mp3 > output.mp3

最后,通过工具MP3Val运行它们以修复任何流错误,而无需强制完全重新编码:

mp3val output.mp3 -f -nb
(来源)

  • 那么不可能做到无损吗? (2认同)