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?
migrated from stackoverflow.com 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.
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.
If you have three files called 1.mp3, 2.mp3 and 3.mp3, the command would look like this:
Note that the single-quotes are important.
First, you have to create a plain text file containing lines like:
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:
The actual ffmpeg command you would use would be:
See here for a bit more information.