Preserving metadata during transcoding ensures that context (such as creation date, author, copyright, or recording device) remains attached to the media asset. When converting AVI files to WebM, metadata loss can occur because these formats store metadata differently: AVI uses RIFF INFO tags, while WebM uses the EBML metadata model from the Matroska specification. This guide shows how to extract, map, and verify metadata using FFmpeg tools in automated or manual workflows.
Inspect and Extract Metadata from the AVI File
Before transcoding, extract and review existing metadata so you can map key fields later.
Sample Command:
ffprobe -v quiet -show_format -print_format json input.avi > avi_metadata.jsonExample Output Snippet:
{
"format": {
"filename": "input.avi",
"tags": {
"title": "Family Reunion 2010",
"date": "2010-06-12",
"artist": "Sony DSC-HX5V",
"comment": "Shot at Riverside Park"
}
}
}This JSON file becomes your reference for recreating or verifying metadata after conversion.
Transcode the Video with Metadata Mapping
AVI and WebM differ structurally, so direct metadata copying may not always work. However, FFmpeg"s -map_metadata parameter enables the mapping of compatible fields from input to output.
Transcoding Command:
ffmpeg -i input.avi -c:v libvpx-vp9 -c:a libopus -map_metadata 0 output.webmExplanation:
- -map_metadata 0 copies the available global metadata fields from the first input.
- libvpx-vp9 encodes the video into VP9 for efficient compression and web compatibility.
- libopus encodes the audio stream into Opus for optimal playback quality.
The process re-encodes while attempting to carry compatible metadata across container formats.
Verify Metadata in the WebM Output
After the conversion, confirm which metadata fields survived. Use FFprobe again to ensure that critical tags remain.
Command:
ffprobe -v quiet -show_format -print_format json output.webm > webm_metadata.jsonCompare the metadata between the AVI and WebM JSON outputs to verify field mapping. Supported fields like title, artist, and date often carry over, while unsupported or nonstandard ones may drop.
To Reapply Missing Fields:
ffmpeg -i output.webm -metadata title="Family Reunion 2010" \
-metadata date="2010-06-12" -metadata comment="Shot at Riverside Park" \
-c copy final.webmThis re-injects metadata without re-encoding the streams.
Automating Batch Conversions
In large-scale projects, automate conversions using shell or Python scripts that extract metadata, transcode, and verify outputs.
Shell Example:
for f in *.avi; do
base=$(basename "$f" .avi)
ffprobe -v quiet -show_format -print_format json "$f" > "${base}_meta.json"
ffmpeg -i "$f" -c:v libvpx-vp9 -c:a libopus -map_metadata 0 "${base}.webm"
ffprobe -v quiet -show_format -print_format json "${base}.webm" > "${base}_webm_meta.json"
doneThis batch script processes all AVI files in a directory, stores both original and converted metadata, and creates traceable output logs for validation.
Handling Unsupported or Custom Metadata
Some metadata, such as nonstandard RIFF chunks, GPS data, or proprietary editor tags, will not map to WebM. In such cases:
- Extract metadata separately using ffprobe.
- Save it as an external sidecar JSON or XML file (for long-term archival).
- Reinsert essential information manually using -metadata flags or custom scripts.
If WebM players or browsers ignore specific fields, retain metadata externally to maintain provenance without breaking playback compatibility.
Validate and Maintain Metadata Integrity
Always validate both video integrity and associated metadata after batch conversions, especially in archival workflows.
Suggested Checks:
ffplay output.webm
mediainfo output.webmTo maintain metadata consistency over time:
- Use the same FFmpeg version across systems.
- Keep JSON backups of metadata.
- Regularly audit transcoded files to ensure retained fields match organizational metadata standards.

