mediacodec.dev

Watermark a video

Overlaying an image means building a small filter graph: optionally reshape the logo (scale, fade its alpha), then composite it onto the video. The expressions below use the overlay filter’s own variables (W/H for the video, w/h for the logo), so the same command works at any resolution.

Position

overlay

overlay=W-w-M:H-h-M. The traditional spot.

Computed from the frame dimensions, not hardcoded pixels: the logo lands in the same corner whether the video is 720p or 4K.

Margin (px)

overlay
tightinset16

16px in from the edge on both axes.

Distance from the chosen corner, in pixels of the output video.

Logo size

scale=

Use the PNG at its native size.

Scales the logo before compositing. Height follows automatically to keep its aspect ratio.

Opacity (%)

colorchannelmixer
faintsolid100

Fully opaque: the PNG’s own transparency still applies.

Below 100%, the logo’s alpha channel is multiplied down before compositing, so the video shows through it.

Quality (CRF)

-crf
bettersmaller20

CRF 20: high-quality delivery.

Compositing changes pixels, so the video re-encodes. x264 scale: 18–23 is the useful delivery range.

Your command

ffmpeg -i input.mp4 \
  -i logo.png \
  -filter_complex overlay=W-w-16:H-h-16 \
  -c:v libx264 -crf 20 \
  -preset medium -c:a copy \
  output.mp4

Worth knowing

In the filter graph, [0] is the video and [1] is the logo: the inputs in the order they appear on the command line.

A PNG with transparency composites cleanly; the alpha channel is respected throughout.

Audio is stream-copied: watermarking only touches the picture.

Run this on your own file

no FFmpeg · runs in this tab

The command above needs FFmpeg on a machine. The settings it encodes do not: your browser can perform the same operation on a real file, right here, through WebCodecs.

Drop a video or audio file here, or

Files are processed in this tab and never uploaded.

This task also needs the logo image. Drop it here, or

Files are processed in this tab and never uploaded.

The overlay filter graph becomes a canvas draw over every decoded frame: same maths (W-w-M, alpha multiply), different machinery.

WebCodecs has no CRF, so -crf 20 becomes a bitrate target for the output resolution, using the rule that every 6 CRF steps halve or double the size.

Waiting on a file.