FFmpeg Copy Metadata from Second Input to Output

When processing multiple media files with FFmpeg, the tool by default copies global metadata from the very first input file to the output. This article provides a quick and direct guide on how to override this default behavior using the -map_metadata option, allowing you to copy the global metadata from the second input file (or any subsequent input) to your output file.

To copy global metadata from the second input file to your output, you need to use the -map_metadata flag combined with FFmpeg’s zero-based indexing system. In FFmpeg, the first input file is indexed as 0, and the second input file is indexed as 1.

The Command Syntax

Use the following command structure to achieve this:

ffmpeg -i input1.mp4 -i input2.mp4 -map 0:v -map 0:a -map_metadata 1 -c copy output.mp4

How It Works

By explicitly declaring -map_metadata 1, you prevent FFmpeg from using the metadata of input1.mp4 and force it to write the global metadata tags (such as title, author, creation time, or copyright) from input2.mp4 into the final output.mp4.