I would like to place the audio from a video to another video without an audio (in one command):
ffmpeg.exe -i video1_noAudio.mov -i video2_wAudio.mov -vcodec copy -acodec copy video1_audioFromVideo2.mov
I guess “-map” is the correct way to do it but I got confused with it.
Can you suggest how to resolve it?
Overview of inputs
input_0.mp4has the desired video stream andinput_1.mp4has the desired audio stream:In
ffmpegthe streams look like this:ID numbers
ffmpegrefers to input files and streams with index numbers. The format isinput_file_id:input_stream_id. Sinceffmpegstarts counting from 0, stream1:1refers to the audio frominput_1.mp4.Stream specifiers
This can be enhanced with stream specifiers. For example, you can tell
ffmpegthat you want the first video stream from the first input (0:v:0), and the first audio stream from the second input (1:a:0). I prefer this method because it’s more efficient. Also, it is less prone to accidental mapping because1:1can refer to any type of stream, while2:v:3only refers to the fourth video stream of the third input file.Examples
The
-mapoption instructsffmpegwhat streams you want. To copy the video frominput_0.mp4and audio frominput_1.mp4:This next example will do the same thing:
-map 0:v:0can be translated as: from the first input (0), select video stream type (v), first video stream (0)-map 1:a:0can be translated as: from the second input (1), select audio stream type (a), first audio stream (0)Additional Notes
With
-c copythe streams will be stream copied, not re-encoded, so there will be no quality loss. If you want to re-encode, see FFmpeg Wiki: H.264 Encoding Guide.The
-shortestoption will cause the output duration to match the duration of the shortest input stream.See the
-mapoption documentation for more info.