Lesson 5 of 7

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

ffmpeg -i input.mp4 -vf \ "drawtext=text='yoursite.com':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2" \ output.mp4

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:

Positionx and y values
Top-left (with padding)x=20:y=20
Top-rightx=w-text_w-20:y=20
Bottom-leftx=20:y=h-text_h-20
Bottom-rightx=w-text_w-20:y=h-text_h-20
Centerx=(w-text_w)/2:y=(h-text_h)/2

Add a background box for readability

ffmpeg -i input.mp4 -vf \ "drawtext=text='yoursite.com':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.5:boxborderw=10:x=w-text_w-20:y=h-text_h-20" \ output.mp4

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

ffmpeg -i input.mp4 -vf \ "drawtext=text='Subscribe!':fontsize=36:fontcolor=yellow:x=(w-text_w)/2:y=h-80:enable='between(t,5,10)'" \ output.mp4

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

ffmpeg -i input.mp4 -vf \ "drawtext=text='%{pts\\:hms}':fontsize=20:fontcolor=white:box=1:boxcolor=black@0.4:boxborderw=5:x=20:y=20" \ output.mp4

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

ffmpeg -i video.mp4 -i logo.png \ -filter_complex "overlay=W-w-20:H-h-20" \ output.mp4

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:

ffmpeg -i video.mp4 -i logo.png \ -filter_complex "[1:v]scale=120:-1[logo];[0:v][logo]overlay=W-w-20:H-h-20" \ output.mp4

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:

ffmpeg -i video.mp4 -i logo.png \ -filter_complex "[1:v]colorchannelmixer=aa=0.3,scale=150:-1[logo];[0:v][logo]overlay=W-w-20:H-h-20" \ output.mp4

The aa=0.3 sets the alpha channel to 30%, making the logo semi-transparent.

Center watermark (large, faded)

ffmpeg -i video.mp4 -i watermark.png \ -filter_complex "[1:v]colorchannelmixer=aa=0.15,scale=iw/2:-1[wm];[0:v][wm]overlay=(W-w)/2:(H-h)/2" \ output.mp4

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:

ffmpeg -i video.mp4 -i logo.png \ -filter_complex \ "[1:v]scale=100:-1[logo];[0:v][logo]overlay=W-w-20:20,drawtext=text='yoursite.com':fontsize=20:fontcolor=white:box=1:boxcolor=black@0.4:boxborderw=5:x=20:y=H-40" \ output.mp4

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:

for f in *.mp4; do ffmpeg -i "$f" -i logo.png \ -filter_complex "[1:v]scale=100:-1[logo];[0:v][logo]overlay=W-w-20:H-h-20" \ "watermarked_$f" done

Key Takeaways

  • Use drawtext for text overlays — supports positioning, background boxes, and timed display
  • Use -filter_complex overlay for image/logo watermarks
  • Position expressions: W-w-20:H-h-20 for bottom-right, (W-w)/2:(H-h)/2 for center
  • Control transparency with colorchannelmixer=aa=0.3
  • Chain multiple overlays in one -filter_complex for 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.