I am using ffmpeg for Concatenating two MP3 files together,

I use this command :

ffmpeg -y -i first.mp3 -i second.mp3 -filter_complex "[0:0][1:0] amix=inputs=2:duration=longest" -c:a libmp3lame output.mp3

It works, but there is a little problem, the overlay together!

I want first song plays, and when it finished, second file starts (in output file)

But now they starts at the same time.

How can i change that command, to have a output that contains first song then when the first finished, second plays ?

Plus, I've tried concat command but not worked, I just can use something like what i sent.

  • Also see this stackoverflow question. – dirkt Jun 4 '17 at 6:38

To skip re-encoding, use the concat demuxer:

Create a text file

file '/path/to/first.mp3'
file '/path/to/second.mp3'

and then

ffmpeg -f concat -i list.txt -c copy out.mp3

If re-encoding is fine,

ffmpeg -i first.mp3 -i second.mp3 -filter_complex [0:a][1:a]concat=n=2:v=0:a=1 out.mp3
| improve this answer | |
  • thanks but i couldn't use that, is there anyway to use amix command? – Karami Jun 4 '17 at 7:07
  • for example adding offset to second sound with using amix ? I don't know why concat doesn't work for me. – Karami Jun 4 '17 at 7:07
  • 1
    Yes, but you have to manually supply the duration, and volume will be reduced. ffmpeg -i 1.mp3 -i 2.mp3 -filter_complex "[1]adelay=75000|75000[b];[0][b]amix" out.mp3 75000 is the duration of 2.mp3 in milliseconds. – Gyan Jun 4 '17 at 7:18
  • 1
    Add -map_metadata 1 – Gyan Jun 4 '17 at 7:31
  • 1
    Add -map_metadata 0. if any fields clash, the last specified map_metadata will overwrite the first. – Gyan Jun 4 '17 at 8:00


cat first.mp3 second.mp3 > out.mp3

should just work. You didn't say what goes wrong when you try it.

Alternatively, you can use mp3wrap:

mp3wrap out.mp3 first.mp3 second.mp3 third.mp3 ...

This doesn't re-encode the MP3s like ffmpeg would, it keeps the ID3 tags, and you can split the files again later with mp3split.

I advise against using ffmpeg or similar programs, because reencoding causes loss of quality.

| improve this answer | |
  • You're right ffmpeg is not good , but i have to currently. Is there anyway to use ffmpeg right now? concat doesn't work for me. I have to use amix format – Karami Jun 4 '17 at 7:08
  • if you don't re-encode doesn't that mess up the timecode? – niico Dec 11 '19 at 15:14
  • This is the fastest way but will need some tweaking if you have spaces in the filename. – lacostenycoder Aug 7 at 16:45

you could also use cat [your files] > concat.mp3 which will produce a mp3 file that has multiple headers and ID3 tags. Afterwards you can correct this by invoking mp3val -f -nb concat.mp3.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.