FFmpeg - Metadata: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
[[Category:FFmpeg]] | [[Category:FFmpeg]] | ||
[[Category:Metadata]] | [[Category:Metadata]] | ||
This article describes how to view, remove, and add metadata in media files using FFmpeg. Metadata affects how files are identified, indexed, and displayed by players and libraries. This includes titles, dates, languages, and default tracks. | |||
== What Is Metadata? == | |||
Media containers such as MP4, MKV, MOV and others support embedded metadata. | |||
Typical metadata includes: | |||
* Title | |||
* Author / Artist | |||
* Creation date / release year | |||
* Language of each track | |||
* Default track flags | |||
* Custom tags | |||
Metadata can be useful (e.g., indexing in media servers) but also problematic if inherited unintentionally from source files. | |||
FFmpeg provides full control over reading, stripping, and rewriting this metadata. | |||
== Strip All Metadata == | == Strip All Metadata == | ||
``` | |||
ffmpeg -i <input.file> -map_metadata -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -f mp4 <output.file> | ffmpeg -i <input.file> -map_metadata -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -f mp4 <output.file> | ||
``` | |||
This command removes container-level and stream-level metadata, and ensures bit‑exact output for predictable hashes and reproducible builds. | |||
== Add Title Tag == | == Add a Title Tag == | ||
``` | |||
ffmpeg -i <input.file> -metadata title="flibble" -f mp4 <output.file> | ffmpeg -i <input.file> -metadata title="flibble" -f mp4 <output.file> | ||
``` | |||
This writes a simple title tag into the container metadata. | |||
== Add Year Tag == | == Add a Year Tag == | ||
``` | |||
ffmpeg -i <input.file> -metadata date=0 -f mp4 <output.file> | ffmpeg -i <input.file> -metadata date=0 -f mp4 <output.file> | ||
``` | |||
Replace 0 with the desired year or date (e.g., 2024 or 2024-11-03). | |||
== Add Language Tags == | == Add Language Tags == | ||
``` | |||
ffmpeg -i <input.file> -metadata:s:a:0 language=eng -metadata:s:v:0 language=eng -f mp4 <output.file> | ffmpeg -i <input.file> -metadata:s:a:0 language=eng -metadata:s:v:0 language=eng -f mp4 <output.file> | ||
``` | |||
Assigns language metadata to audio and video streams. | |||
== Set Default Track == | == Set Default Track == | ||
``` | |||
ffmpeg -i <input.file> -disposition:a:0 default -disposition:a:1 0 -f mp4 <output.file> | |||
``` | |||
To set the default subtitle track: | |||
``` | |||
ffmpeg -i <input.file> -disposition:s:0 default -f mp4 <output.file> | |||
``` | |||
== Inspecting Metadata == | |||
``` | |||
ffprobe -v quiet -show_entries format_tags -show_entries stream_tags -of yaml <input.file> | |||
``` | |||
== Related Topics == | |||
* [[FFmpeg – Encoding Optimal Videos for Streaming]] | |||
* [[FFmpeg – Common Tasks]] | |||
* [[Video Compression – Practical Guide]] | |||
* [[Media Containers – MP4 vs MKV vs MOV]] | |||
Latest revision as of 13:51, 14 March 2026
This article describes how to view, remove, and add metadata in media files using FFmpeg. Metadata affects how files are identified, indexed, and displayed by players and libraries. This includes titles, dates, languages, and default tracks.
What Is Metadata?
Media containers such as MP4, MKV, MOV and others support embedded metadata. Typical metadata includes:
- Title
- Author / Artist
- Creation date / release year
- Language of each track
- Default track flags
- Custom tags
Metadata can be useful (e.g., indexing in media servers) but also problematic if inherited unintentionally from source files.
FFmpeg provides full control over reading, stripping, and rewriting this metadata.
Strip All Metadata
``` ffmpeg -i <input.file> -map_metadata -1 -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -f mp4 <output.file> ``` This command removes container-level and stream-level metadata, and ensures bit‑exact output for predictable hashes and reproducible builds.
Add a Title Tag
``` ffmpeg -i <input.file> -metadata title="flibble" -f mp4 <output.file> ``` This writes a simple title tag into the container metadata.
Add a Year Tag
``` ffmpeg -i <input.file> -metadata date=0 -f mp4 <output.file> ``` Replace 0 with the desired year or date (e.g., 2024 or 2024-11-03).
Add Language Tags
``` ffmpeg -i <input.file> -metadata:s:a:0 language=eng -metadata:s:v:0 language=eng -f mp4 <output.file> ``` Assigns language metadata to audio and video streams.
Set Default Track
``` ffmpeg -i <input.file> -disposition:a:0 default -disposition:a:1 0 -f mp4 <output.file> ``` To set the default subtitle track: ``` ffmpeg -i <input.file> -disposition:s:0 default -f mp4 <output.file> ```
Inspecting Metadata
``` ffprobe -v quiet -show_entries format_tags -show_entries stream_tags -of yaml <input.file> ```