Home > Mobile >  How to combine a video with audio from another video using FFMPEG?
How to combine a video with audio from another video using FFMPEG?

Time:11-01

I have two videos of the same length that I'd like to combine. Video A has audio, video B does not. I'd like to take the audio from video A and put it onto Video B. I'd like to do this with FFMPEG, but I can't figure out the arguments I need? Should I use map?

There's a lot of questions about combining a video with audio, but not two videos.

Do I maybe need an intermediate step of converting my original video to audio?

I have tried using this FFMPEG command, and a couple of variations. All of the resulted in just Video A (the one with audio) being the output.

ffmpeg -i videoB.mp4 -i video A.mp4 -c:v copy -c:a aac output.mp4

CodePudding user response:

Try this as a starter

ffmpeg -i videoB.mp4 -i video A.mp4 
  -filter_complex [0:v][1:a][1:v][1:a]concat=n=2:v=1:a=1[vout][aout]
  -map [vout] -map [aout] -c:v h264 -c:a aac output.mp4

You must reencode though.

  • Related