Quick tip: concatenate MP3s on the command line

Posted on

Joshua Barratt posted a quick hack for concatenating MP3s here:

find . -name '*.mp3' -exec lame --decode '{}' - ';' | lame -a --tt "Title" --tl "Album" --ta "Artist" -b 96 - concatenat.mp3

LAME will decode the MP3s to WAV files and concatenate these to a single stream, which is then passed to LAME for reencoding. If you do it this way, however, the WAV headers of the files following the first one will end up being interpreted as waveform, which may lead to noticeable glitches at the seams. This one is better (and shorter):

cat *.mp3 | lame --decode - - | lame -a --tt "Title" --tl "Album" --ta "Artist" -b 96 - concatenat.mp3

LAME will complain about the MP3 headers within the stream, but it will actually skip them over, so no header data ends up in the waveform!

2 thoughts on “Quick tip: concatenate MP3s on the command line

  1. Hi,

    thx, for your post. Just needed this, but I’ve two remarks:

    First, the ‘–mp3input’ flag should be used, as stated in the manpage: “For stdin or MP3 files which do not end in .mp3 you need to use this switch.”.

    Second, why do you think the .wav decode part is neccessary? In my opinion this step could be easily skipped ending up with something like:
    # cat *.mp3 | lame –mp3input -a –tt “Title” –tl “Album” –ta “Artist” -b 96 – concatenat.mp3


    1. Hi gnux, and sorry for the long delay – somewhat busy right now 🙂 Your suggestions really make sense, I was looking for a quick fix and probably just overlooked those parameters. So, even better! Best, J.

Leave a Reply

Your email address will not be published. Required fields are marked *