Using ffmpeg to copy metadata from one file to another

17

3

I want to use ffmpeg to copy all meta data not associated with core aspects of a video (frame rate, resolution) from one video to another. Is there a simple way to do this with a single command?

David

Posted 2015-11-05T02:53:23.477

Reputation: 325

Answers

19

Use -map_metadata.

In this example the global and stream metadata will be copied from in0.mkv. The video and audio streams will be stream copied from in1.mkv:

ffmpeg -i in0.mkv -i in1.mkv -map 1 -c copy \
# copies all global metadata from in0.mkv to out.mkv  
-map_metadata 0 \
# copies video stream metadata from in0.mkv to out.mkv
-map_metadata:s:v 0:s:v \
# copies audio stream metadata from in0.mkv to out.mkv
-map_metadata:s:a 0:s:a \
out.mkv

This will result in something like:

Output #0, matroska, to 'out.mkv':
  Metadata:
    title           : Global Title
    AUTHOR          : Global Author
    Stream #0:0: Video: h264
    Metadata:
      title           : Stream 0 Title
    Stream #0:1: Audio: vorbis
    Metadata:
      title           : Stream 1 Title

By default global metadata is copied from the first input file, so -map_metadata 0 could probably be omitted.

llogan

Posted 2015-11-05T02:53:23.477

Reputation: 31 929

1If your source video is a .mov file you need to also add the flag -movflags use_metadata_tags or the output video won't contain the metadata. – Mastergalen – 2019-08-28T20:55:59.950

-3

If all you need is the basics (creation date, etc), then touch -r FILE1 FILE2 Will work as a charm coping metadata from FILE1 to FILE2

Emiliano

Posted 2015-11-05T02:53:23.477

Reputation: 1

If you read the question, the objective is the video meta data, not the file meta data. – fixer1234 – 2016-10-27T20:39:01.817