(FFmpeg) How to Replace the Audio on a Video?

There are times when the audio on a video needs to be replaced. Here filters are not even needed to replace audio but the use of ​-map becomes important to understand:

$ ffmpeg -i input.mp4 -i input.mp3 -map 0:v -map 1:a -shortest output.mp4

Here the video from the first input and the audio from the second input is mapped to the output.

Challenge:​ Using the same concepts in the above example, if two inputs were videos, how would you replace the first input video with the second input video but keep the first input’s audio?

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon