Watermarks and Overlays
Add image watermarks, text overlays, logos, and timestamps to videos. Control position, opacity, size, and timing.
Two Types of Overlays
FFmpeg supports two main overlay approaches: text overlays using the drawtext filter, and image overlays using the overlay filter. Text is simpler and renders from a string. Image overlays let you use PNG logos, watermark graphics, or any image file.
Text Overlays with drawtext
We touched on drawtext briefly in Lesson 1. Here we will go deeper into positioning, styling, and timing.
Basic centered text
The expressions w, h, text_w, and text_h are built-in variables for the video width, video height, rendered text width, and rendered text height.
Position presets
Common positioning formulas you can drop into the x= and y= parameters:
| Position | x and y values |
|---|---|
| Top-left (with padding) | x=20:y=20 |
| Top-right | x=w-text_w-20:y=20 |
| Bottom-left | x=20:y=h-text_h-20 |
| Bottom-right | x=w-text_w-20:y=h-text_h-20 |
| Center | x=(w-text_w)/2:y=(h-text_h)/2 |
Add a background box for readability
The box=1 enables a background rectangle. boxcolor=black@0.5 sets it to 50% opacity black. boxborderw=10 adds 10 pixels of padding around the text.
Show text only during a time window
The enable='between(t,5,10)' expression shows the text only between seconds 5 and 10. Use this for timed CTAs, chapter markers, or temporary annotations.
Dynamic timestamp
The %{pts\:hms} expression renders the current timestamp in HH:MM:SS format. Useful for debugging, surveillance footage, or review copies.
Image Overlays (Logos and Watermarks)
For PNG logos, watermark images, or any graphic overlay, use a second input with the overlay filter:
Logo in the bottom-right corner
In the overlay filter, W and H are the main video dimensions, while w and h are the overlay image dimensions. This positions the logo 20 pixels from the bottom-right edge.
Scale the logo before overlaying
If the logo is too large, scale it down first in the filter chain:
This scales the logo to 120 pixels wide (preserving aspect ratio) before placing it.
Semi-transparent watermark
If your logo is a PNG with transparency, it will overlay naturally. To reduce its opacity further, use the colorchannelmixer filter:
The aa=0.3 sets the alpha channel to 30%, making the logo semi-transparent.
Center watermark (large, faded)
This scales the watermark to half the video width at 15% opacity and centers it. A common pattern for review copies or proof videos.
Combining Multiple Overlays
You can chain drawtext and image overlays in the same command:
This places a logo in the top-right and a URL in the bottom-left — a common branding setup for marketing videos.
Batch Watermarking
Apply the same watermark to every video in a folder:
Key Takeaways
- Use
drawtextfor text overlays — supports positioning, background boxes, and timed display - Use
-filter_complex overlayfor image/logo watermarks - Position expressions:
W-w-20:H-h-20for bottom-right,(W-w)/2:(H-h)/2for center - Control transparency with
colorchannelmixer=aa=0.3 - Chain multiple overlays in one
-filter_complexfor combined branding
Try This With FFmpeg Micro
Instead of running FFmpeg locally, you can use FFmpeg Micro's API to process videos in the cloud. No installation required.