8

Neither cat nor mp3wrap are working for me. They merge the files, but the when playing the resulting file, the audio length information is wrong. That is, it show the length of the 1st part (the part which was the 1st file), then the length of the 2nd ... . And so on.

Other alternative that might work? In the past I was happy with ffmpeg but it was deprecated.

6
  • Since when is ffmpeg deprecated? A few more programs that might work: cutmp3 and quelcom (haven't verified they'll actually join two mp3 files).
    – derobert
    Commented Apr 26, 2016 at 18:44
  • @derobert: I don't know how long. But Ubuntu is clear about this when I try to run ffmpeg: THIS PROGRAM IS DEPRECATED This program is not developed anymore and is only provided for compatibility. Use avconv instead (see Changelog for the list of incompatible changes).
    – Pierre B
    Commented Apr 29, 2016 at 19:41
  • That's a warning from libav's ffmpeg-compatability-wrapper. You could use avconv, but really—the libav fork is dead, ffmpeg is not. You should just ignore the warning. ffmpeg is not deprecated.
    – derobert
    Commented Apr 29, 2016 at 19:44
  • 1
    This askubuntu post covers the ffmpeg deprecation warning in detail. So this SuperUser post might be a good answer to this problem.
    – user86219
    Commented Nov 8, 2017 at 17:09
  • Note that as of in Aug 2018, it is not deprecated. You can reach ffmpeg community through irc channels: #ffmpeg and #ffmpeg-devel ffmpeg.org/contact.html and their github on github.com/FFmpeg/FFmpeg
    – Jun
    Commented Aug 31, 2018 at 22:21

5 Answers 5

6

ffmpeg -i "concat:1.mp3|2.mp3|3.mp3" -acodec copy output.mp3

If you use Python, you can use a subprocess

import subprocess

subprocess.call(['ffmpeg', '-i', 'concat:1.mp3|2.mp3|3.mp3', '-acodec', 'copy', 'output.mp3'])

You can also have the paths to your mp3 in a file.

# audio-to-process.txt
file '/path/to/mp3-1'
file '/path/to/mp3-2'
file '/path/to/mp3-3'

Then,

ffmpeg -f concat -safe 0 -i audio-to-process.txt -c copy output

The -safe 0 flag is not needed if the file paths are relative.

ffmpeg concatenate api API page

5

I use sox. In order to concatenate mp3 files :

 sox file1.mp3 file2.mp3 file3.mp3 output.mp3

Sox can also be used to perform many other sound operations.

update

To avoid license problems, some Linux distributions don't have sox mp3 support by default. But normally there is a package...

  • fedora: sudo dnf install sox-plugins-freeworld
  • debian & friends sudo apt-get install libsox-fmt-mp3 (untested...)
2
  • used like this sox will create a lossy even more compressed result.
    – Kuhlambo
    Commented Oct 5, 2021 at 12:17
  • This is the most elegant method I've found yet, thank you.
    – Sysfu
    Commented Oct 24, 2023 at 21:17
0

may I suggest the linux version of audacity? very user friendly and it is structured for audio files

2
  • But requires a GUI. Think the OP is after a command line utility. Good suggestion otherwise
    – ivanivan
    Commented Aug 31, 2018 at 22:39
  • Audacity is not an ideal choice, EXTREMELY slow when you use very long files. Encoding of mp3s is only single threaded and can take a long time. On a decent quad core, 10 hours of mp3 encoding took up to a whole hour, the CPU was probably 20% used during that time. Commented May 2, 2019 at 1:29
0

I found this question while searching for the same. Just discovered this great utility while digging further.

https://www.dmulholl.com/dev/mp3cat.html

Easy as

mp3cat *.mp3

Which will merge the files into one called 'output.mp3' by default.

-1

A simple way:

  1. cd into the directory of the files
  2. Run ffmpeg -f concat -safe 0 -i <(for f in ./*.mp3; do echo "file '$PWD/$f'"; done) -c copy ./output.mp3

This only works if you cd into the actual directory and not to a shortcut to it.

More at the ffmpeg wiki page on Concatenate

2
  • What do you mean by "This only works if you cd into the actual directory and not to a shortcut to it"? I don't see a restriction here. Are you thinking of Windows shortcuts? Commented Aug 8, 2023 at 8:09
  • This answer being discussed in unix.stackexchange.com/q/753493/70524
    – muru
    Commented Aug 10, 2023 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .