Combine multiple mp3 files with ffmpeg

less than 1 minute read

Combine all mp3 files under the directory into one mp3 file.
I found this to be the easiest of all the research and trials.
You can do it with two commands.

environment

  • mac OS : Catalina version 10.15.6
  • ffmpeg : stable 4.3.1 (bottled)

step 1

Create a list (mylist.txt) of all the mp3 files you want to combine.
Execute the following in the directory that contains the files you want to combine.

$ for f in *.mp3; do echo "file '$f'" >> mylist.txt; done

Contents of the list of mp3 files (mylist.txt)

file 'file1.mp3'
file 'file2.mp3'
...

Step 2

Use the list of created mp3 files to combine them into one mp3 file.
Execute the following in the directory that contains the files you want to combine.

$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp3
  • Output.mp3 is the output mp3 file name

You may be able to do it without entering -safe 0,
In my environment, I couldn’t get the error [concat @ 0x7fcb00008200] Unsafe file name'input.mp3' mylist.txt: Operation not permitted.

.
.
.

reference