Display Custom Metadata on Video with FFmpeg
This article demonstrates how to extract and display custom metadata
values—such as copyright, album name, artist, or track title—directly
onto a video screen using FFmpeg. By utilizing FFmpeg’s powerful
drawtext video filter and its metadata expansion
capabilities, you can dynamically burn text from your file’s metadata
tags directly into the video frames.
Step 1: Verify the Metadata with FFProbe
Before displaying metadata, you must ensure the target keys (like
copyright or album) actually exist in your
source file. Run the following command to inspect your file’s
metadata:
ffprobe -show_entries format_tags -v quiet -of csv="p=0" input.mp4This will list all the global metadata tags embedded in the file.
Identify the exact names of the keys you want to display (e.g.,
copyright, album, artist).
Step 2: Use the drawtext Filter to Display Metadata
To overlay metadata on the video, use the drawtext
filter with the %{metadata:key_name} expansion companion.
Because colons are used as separators in FFmpeg filterchains, you must
escape the colon inside the metadata tag with a backslash
(\:).
Here is the basic command to overlay the copyright metadata:
ffmpeg -i input.mp4 -vf "drawtext=text='Copyright\: %{metadata\:copyright}':x=20:y=20:fontsize=24:fontcolor=white" -c:a copy output.mp4Step 3: Displaying Multiple Metadata Fields
You can display multiple metadata fields, such as both the
album and the copyright information,
by using multiple drawtext filters separated by a comma or
by using line breaks.
To display them on separate lines at the top-left of the video:
ffmpeg -i input.mp4 -vf "drawtext=text='Album\: %{metadata\:album}':x=20:y=20:fontsize=24:fontcolor=white, drawtext=text='Copyright\: %{metadata\:copyright}':x=20:y=50:fontsize=24:fontcolor=white" -c:a copy output.mp4Command Breakdown
-vf: Specifies that a video filtergraph is being used.drawtext: The filter used to render text on top of the video.text='... %{metadata\:key}': Defines the text to display. The%{metadata\:key}syntax pulls the value of the specified metadata key.x=20:y=20: Sets the horizontal (x) and vertical (y) pixel coordinates where the text will be placed, starting from the top-left corner.fontsize=24:fontcolor=white: Customizes the appearance of the text on the screen.-c:a copy: Copies the audio stream without re-encoding to save processing time.