Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to to make 10 mins videos with 5 x 2 mins mp3 samples stitched together. How would you do that with ffmpeg from the command line?

share|improve this question

migrated from Dec 23 '09 at 19:32

This question came from our site for professional and enthusiast programmers.

I don't think FFMPEG can do this without some crazy command-line fu, but MP3Wrap was designed for this purpose.

You could also use the cat command on Linux:

cat file1.mp3 file2.mp3 > combined.mp3

which will combine file1.mp3 and file2.mp3

or the copy command on Windows:

copy /b *.mp3 c:\combined.mp3

which will combine all mp3 files in your current directory to C:\combined.mp3.

but the cat and copy methods often have undesired effects. The main problem is that the wrong length for the mp3 file could be reported, which may give some audio players problems -- and lost ID3 tags. MP3Wrap solves both of these issues, and is available for Linux and Windows.

share|improve this answer

With a recent ffmpeg, you can use either the concat protocol (file-level concatenation) or the concat demuxer (or the concat filter, but that requires re-encoding). The protocol is less resource intensive and, IIRC, should work fine on MP3s; but if that doesn't work, you should use the demuxer instead.

Concat Protocol

If you have three files called 1.mp3, 2.mp3 and 3.mp3, the command would look like this:

ffmpeg -i 'concat:1.mp3|2.mp3|3.mp3' -c copy output.mp3

Note that the single-quotes are important.

Concat Demuxer

First, you have to create a plain text file containing lines like:

file '1.mp3'
file '2.mp3'
file '3.mp3'

You can also provide the absolute or relative path to each MP3 file.

If you're working on a bash shell, you can use a command like this to generate the file quickly, containing all MP3s in a directory:

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

The actual ffmpeg command you would use would be:

ffmpeg -f concat -i inputs.txt -c copy output.mp3

See here for a bit more information.

share|improve this answer

You must log in to answer this question.

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