小智 7
ffmpeg -i "concat:1.mp3|2.mp3|3.mp3" -acodec copy output.mp3
如果使用 Python,则可以使用子进程
import subprocess
subprocess.call(['ffmpeg', '-i', 'concat:1.mp3|2.mp3|3.mp3', '-acodec', 'copy', 'output.mp3'])
Run Code Online (Sandbox Code Playgroud)
您还可以在文件中包含 mp3 的路径。
# audio-to-process.txt
file '/path/to/mp3-1'
file '/path/to/mp3-2'
file '/path/to/mp3-3'
Run Code Online (Sandbox Code Playgroud)
然后,
ffmpeg -f concat -safe 0 -i audio-to-process.txt -c copy output
Run Code Online (Sandbox Code Playgroud)
如果文件路径是相对的,则不需要 -safe 0 标志。
我用sox
。为了连接 mp3 文件:
sox file1.mp3 file2.mp3 file3.mp3 output.mp3
Run Code Online (Sandbox Code Playgroud)
Sox 还可用于执行许多其他声音操作。
为了避免许可证问题,某些 Linux 发行版默认不支持 sox mp3。不过一般都会有一个包...
sudo dnf install sox-plugins-freeworld
sudo apt-get install libsox-fmt-mp3
(未经测试...)