Add Text Watermark to Video with FFmpeg
Adding a text watermark to a video is a common task for branding, copyright protection, or adding captions. This guide provides a quick, step-by-step walkthrough on how to overlay static, styled, or dynamic text onto a video using the powerful FFmpeg command-line tool in Linux. You will learn the basic syntax, how to customize fonts and colors, and how to precisely position your watermark.
Basic Syntax for Text Overlays
To add text to a video, FFmpeg utilizes the drawtext
video filter. This filter requires your system to have access to the
fonts, usually managed via fontconfig.
Here is the fundamental command to overlay a simple text watermark:
ffmpeg -i input.mp4 -vf "drawtext=text='My Watermark':x=10:y=10:fontsize=24:fontcolor=white" -c:a copy output.mp4In this command:
-i input.mp4: Specifies the input video file.-vf "drawtext=...": Applies the video filter graph for drawing text.text='My Watermark': The actual string you want to display.x=10:y=10: The pixel coordinates from the top-left corner where the text starts.fontsize=24: The size of the text font.fontcolor=white: The color of the text.-c:a copy: Copies the audio stream without re-encoding it, which saves processing time.
Customizing Fonts and Styling
For a more professional appearance, you can specify a specific font file path and add background boxes or borders to make the text stand out against varying video backgrounds.
ffmpeg -i input.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:text='Copyright 2026':x=20:y=20:fontsize=30:fontcolor=yellow:box=1:boxcolor=black@0.5:boxborderw=5" -c:a copy output.mp4Key styling parameters used here include:
fontfile: The absolute path to the.ttfor.otffont file on your Linux system.box=1: Enables a background rectangle behind the text.boxcolor=black@0.5: Sets the background box to black with a 50% opacity (alpha) layer.boxborderw=5: Adds a padding/border width around the text inside the box.
Advanced Positioning
FFmpeg allows you to use internal variables like w
(video width), h (video height), tw (text
width), and th (text height) to dynamically position your
watermark.
Center of the video:
-vf "drawtext=text='Centered Text':x=(w-tw)/2:y=(h-th)/2:fontsize=32:fontcolor=white"Bottom-right corner (with a 20-pixel margin):
-vf "drawtext=text='Property of Company':x=w-tw-20:y=h-th-20:fontsize=24:fontcolor=white@0.7"Using these variables ensures your watermark stays relatively positioned in the correct location regardless of the input video’s resolution.