Display Video Metadata on Screen with FFmpeg
This article demonstrates how to extract and display custom metadata
values, such as a video’s title or creation date, directly on the video
screen using FFmpeg. By utilizing the drawtext video filter
alongside FFmpeg’s text expansion feature, you can dynamically overlay
metadata onto your video frames during the rendering process.
Step 1: Ensure Your Video Has Metadata
Before displaying metadata, the input file must contain the tags you want to read. You can embed custom metadata (like a title) into a video using the following command:
ffmpeg -i input.mp4 -metadata title="My Custom Video Title" -codec copy prepared.mp4Step 2: Overlay the Metadata onto the Video
To burn the metadata onto the video frame, use the
drawtext filter. FFmpeg can dynamically read metadata tags
using the %{metadata\:key_name} syntax.
Run the following command to display the title:
ffmpeg -i prepared.mp4 -vf "drawtext=text='%{metadata\:title}':x=50:y=50:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5" -codec:a copy output.mp4Parameter Breakdown
drawtext: The video filter used to render text on top of video frames.text='%{metadata\:title}': Instructs FFmpeg to fetch the value of thetitlemetadata key. The colon must be escaped with a backslash (\:) so FFmpeg does not confuse it with a filter parameter separator.x=50:y=50: Sets the horizontal (x) and vertical (y) pixel coordinates where the text will appear (measured from the top-left corner).fontsize=24:fontcolor=white: Customizes the text size and color.box=1:boxcolor=black@0.5: Draws a semi-transparent black background box behind the text to ensure readability against bright video backgrounds.
Displaying Multiple Metadata Fields
You can combine multiple metadata fields or add static label text within the same filter. For example, to display both the title and the creation time:
ffmpeg -i prepared.mp4 -vf "drawtext=text='Title\: %{metadata\:title} | Created\: %{metadata\:creation_time}':x=50:y=50:fontsize=20:fontcolor=white:box=1:boxcolor=black@0.5" -codec:a copy output.mp4