Watermark and Logo Overlay — How to Use the overlay Filter
The overlay filter is used to burn logos and copyright notices into video. It takes two video inputs and outputs them as a single composited image. This article walks through everything from basic usage to advanced position variables, transparent PNGs, and time-limited display.
Verified with: ffmpeg 6.1
1. overlay Filter Basics
The overlay filter requires two inputs. Specify the video and logo image separately with -i, and composite them with -filter_complex.
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=10:10" output.mp4
overlay=X:Y— Places the top-left corner of the logo at coordinate (X, Y) on the main video (origin is top-left)- The above places the logo 10px from the left and 10px from the top
2. Built-in Variables for Position
Using variables instead of fixed numbers for coordinates allows the position to automatically adapt when the video size changes.
| Variable | Meaning |
|---|---|
main_w / W | Width of the main video |
main_h / H | Height of the main video |
overlay_w | Width of the overlay (logo) |
overlay_h | Height of the overlay (logo) |
Bottom-right placement (the most commonly used pattern)
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=main_w-overlay_w-10:main_h-overlay_h-10" output.mp4
main_w - overlay_w - 10→ X coordinate with a 10px margin from the right edgemain_h - overlay_h - 10→ Y coordinate with a 10px margin from the bottom edge
Other common positions:
| Position | X expression | Y expression |
|---|---|---|
| Top-left | 10 | 10 |
| Top-right | main_w-overlay_w-10 | 10 |
| Bottom-left | 10 | main_h-overlay_h-10 |
| Bottom-right | main_w-overlay_w-10 | main_h-overlay_h-10 |
| Center | (main_w-overlay_w)/2 | (main_h-overlay_h)/2 |
3. Using Transparent PNGs Directly (Alpha Channel Support)
When using a PNG logo with transparent areas, you can adjust the size with the scale filter before compositing.
ffmpeg -i input.mp4 -i logo.png -filter_complex "[1:v]scale=100:-1[wm];[0:v][wm]overlay=10:10" output.mp4
Filter graph explanation:
[1:v]scale=100:-1[wm]— Resizes the logo (second input) to 100px wide (preserving aspect ratio) and labels it[wm][0:v][wm]overlay=10:10— Composites the main video and the resized logo at position (10, 10)
Key point: FFmpeg automatically handles transparency for alpha channel PNGs. No special options are required.
4. Display Only During a Specific Time Range (enable Option)
Using the enable option, you can specify a time range in seconds during which the logo is visible.
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=10:10:enable='between(t,0,5)'" output.mp4
t— Current timestamp (in seconds)between(t, start_seconds, end_seconds)— Function that returns1(active) within that range- The above displays the logo only during seconds 0–5 of the video
This is useful when you want the logo to appear only during a specific section (e.g., intro or outro) rather than the entire video.
5. Summary: The Standard Bottom-Right Logo Command
This is the most commonly used pattern in real-world use.
ffmpeg -i input.mp4 -i logo.png -filter_complex "[1:v]scale=150:-1[wm];[0:v][wm]overlay=main_w-overlay_w-20:main_h-overlay_h-20" output.mp4
- Resizes the logo to 150px wide
- Places it with a 20px margin at the bottom-right
- Natural compositing that preserves the alpha channel
Common Notes
- Difference between
-filter_complexand-vf: Use-filter_complexwhen there are two or more inputs.-vfcan only be used for single-input cases - Logo format: JPEG cannot have an alpha channel, so use PNG (or WebP) for transparent logos
- Output codec: By default, re-encoding is done with
libx264/aac. Add-c:v libx264 -crf 18etc. if you want to specify a codec
Related Articles
Tested with: ffmpeg 6.1.1 / Ubuntu 24.04 (GitHub Actions runner)
Primary sources: ffmpeg.org/ffmpeg.html / ffmpeg.org/ffmpeg-filters.html / trac.ffmpeg.org