FFmpeg: Copy Global Metadata but Discard Stream Metadata

This article explains how to use FFmpeg to preserve global container-level metadata—such as title, artist, or genre—while stripping away individual stream-level metadata, such as encoder details, handler names, or language tags from specific video and audio tracks.

By default, FFmpeg attempts to copy both global and stream-level metadata from the input file to the output file. To override this behavior and isolate the global metadata, you must explicitly map the global metadata while disabling the stream-level metadata mapping using the -map_metadata option.

The FFmpeg Command

To copy global metadata and discard stream-level metadata, use the following command structure:

ffmpeg -i input.mp4 -map_metadata 0 -map_metadata:s -1 -c copy output.mp4

Command Breakdown

  • -i input.mp4: Specifies the source media file.
  • -map_metadata 0: Tells FFmpeg to copy the global metadata from the first input file (index 0) to the output file.
  • -map_metadata:s -1: The :s specifier targets all streams (video, audio, subtitles). Setting the index to -1 tells FFmpeg to discard all stream-level metadata.
  • -c copy: Stream copies the video and audio payloads without re-encoding, ensuring the process is fast and lossless.
  • output.mp4: The destination file.

Target Specific Streams (Optional)

If you want to discard metadata for only specific stream types rather than all streams, you can define them individually:

  • To discard only audio stream metadata:

    ffmpeg -i input.mp4 -map_metadata 0 -map_metadata:s:a -1 -c copy output.mp4
  • To discard only video stream metadata:

    ffmpeg -i input.mp4 -map_metadata 0 -map_metadata:s:v -1 -c copy output.mp4