I would like to add multiple mp3 files to an mp4 file. For adding a single mp3 to an mp4, I used this command with success:

"-i /path/to/mp4File -i /path/to/soundmp3File -codec copy -shortest path/to/output/fileWithSound"

But I'm stuck with adding another mp3. I tried this, but it didn't work:

"-i /path/to/mp4File -i /path/to/soundmp3File1 -i path/to/soundmp3File2 -codec copy -shortest path/to/output/fileWithSounds"

How can I make it work with multiple audio files?



-i /path/to/mp4File
-i /path/to/soundmp3File1
-i path/to/soundmp3File2
-map 0 -map 1:a -map 2:a
-codec copy -shortest path/to/output/fileWithSounds

FFmpeg will automatically select one video and one audio stream from among all the inputs. -map options are required to include all streams.

  • For some reason only one audio stream ends up in my output file. Multiple streams only work if I amerge, but that's slow. I use the command you pasted. Unfortunately I accepted before trying. – WPMed Nov 19 '18 at 11:37
  • Share full log. – Gyan Nov 19 '18 at 11:54
  • I think I may have misunderstood multiple things about mp4. So if I add multiple audiotracks, will a player actually play all the tracks included? So I think the reason I only hear one audio in the output is that the player picks one. Does it make sense? – WPMed Nov 19 '18 at 12:02
  • 1
    Yes, that's expected. You'll need amix filter if you want to hear all sounds at once - this will produce one track with all tracks mixed. A video player will only play one track at a time. – Gyan Nov 19 '18 at 12:45

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.