Add a watermark to a video with FFmpeg

Feed the logo in as a second input and draw it with overlay=W-w-24:H-h-24 for the bottom-right corner with a 24 px margin. Scale the logo first, and add format=rgba,colorchannelmixer=aa=0.6 for 60% opacity. The video is re-encoded, so copy the audio with -c:a copy.

Fixed size Re-encode

You know the video size and want the logo at an exact pixel size.

ffmpeg -i in.mp4 -i logo.png -filter_complex "[1:v]scale=96:-1[logo];[0:v][logo]overlay=W-w-24:H-h-24" -c:a copy out.mp4

A 96x96 logo 24 px in from the right and bottom edges on all 720 frames. The audio is copied untouched.

Logo
96x96, 24 px from the corner
Audio
Copied, not re-encoded
Run time
2.8 s
Output
8.7 MB
Relative size Re-encode

Videos of different sizes go through the same command and the logo should keep its share of the frame.

ffmpeg -i in.mp4 -i logo.png -filter_complex "[1:v][0:v]scale=rw/10:-1,format=rgba,colorchannelmixer=aa=0.6[logo];[0:v][logo]overlay=W-w-24:H-h-24" -c:a copy out.mp4

The logo is 128 px wide, a tenth of the 1280 px frame, at 60% opacity. The same command on a 3840x2160 video drew it 384 px wide.

Logo width
10% of the video
Opacity
60%
Run time
2.8 s
Output
8.8 MB

Proof

The same frame, watermarked four ways

Each picture is frame 240 (0:10) of the output, or the output image. The logo is white, so the bright wall is the hard case.
scale=96:-1, overlay=W-w-24:H-h-24 Fully opaque, 24 px margin
Video frame with a small white Rendobar logo in the bottom-right corner
96 px The logo at full opacity. W and H are the video size, w and h the logo size, so the expression keeps the margin at any resolution.
scale=rw/10:-1, colorchannelmixer=aa=0.6 A tenth of the frame width, 60% opacity
Video frame with a larger, semi-transparent Rendobar logo in the bottom-right corner
128 px rw is the width of the second input to scale, the video. The wall shows through the logo.
overlay=(W-w)/2:(H-h)/2, aa=0.3 Centered at 30% opacity
Video frame with a large, faint Rendobar logo in the center
320 px A large, faint mark over the middle of the picture. At 30% a white logo is hard to see on a bright scene.
logo.jpg: aa=0.5, then format=rgba, then colorkey A JPEG logo has no transparency to fade
Three crops: a solid black square behind the logo, a half-transparent black square, and a clean half-transparent logo
Left: colorchannelmixer=aa=0.5 alone does nothing, the black background stays solid. Middle: with format=rgba the whole square fades, background included. Right: colorkey=black:0.2 removes the black first.

Footage: Sintel, © Blender Foundation, CC BY 3.0.

Run it

Run it on Rendobar

Send the same command from your code. The job fetches each input from its URL and returns the output file's URL when it finishes.

job.ts
import { createClient } from "@rendobar/sdk";
const rb = createClient({ apiKey: process.env.RENDOBAR_API_KEY });
const job = await rb.jobs.run({
type: "ffmpeg",
inputs: {
"in.mp4": "https://cdn.rendobar.com/examples/add-watermark/in.mp4",
"logo.png": "https://cdn.rendobar.com/examples/add-watermark/logo.png",
},
params: {
command: "ffmpeg -i in.mp4 -i logo.png -filter_complex \"[1:v][0:v]scale=rw/10:-1,format=rgba,colorchannelmixer=aa=0.6[logo];[0:v][logo]overlay=W-w-24:H-h-24\" -c:a copy out.mp4",
},
});
console.log(job.output.file.url);

Install with npm i @rendobar/sdk. jobs.run() submits and waits, so it returns the finished job in one call.

terminal
curl https://api.rendobar.com/jobs \
-H "Authorization: Bearer $RENDOBAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "ffmpeg",
"inputs": {
"in.mp4": "https://cdn.rendobar.com/examples/add-watermark/in.mp4",
"logo.png": "https://cdn.rendobar.com/examples/add-watermark/logo.png"
},
"params": {
"command": "ffmpeg -i in.mp4 -i logo.png -filter_complex \"[1:v][0:v]scale=rw/10:-1,format=rgba,colorchannelmixer=aa=0.6[logo];[0:v][logo]overlay=W-w-24:H-h-24\" -c:a copy out.mp4"
}
}'

Returns immediately with a job id. Poll GET /jobs/{id} or register a webhook rather than blocking on the request.

Every variant

Pick the command for your case

Each one ran on the same input. The line under it is what came out. Run times are the best of three runs with FFmpeg 8.0 on one desktop machine, so read them as relative.

  1. Put a transparent watermark in the center

    Re-encode
    ffmpeg -i in.mp4 -i logo.png -filter_complex "[1:v]scale=320:-1,format=rgba,colorchannelmixer=aa=0.3[logo];[0:v][logo]overlay=(W-w)/2:(H-h)/2" -c:a copy out.mp4

    A 320 px logo at 30% opacity in the middle of the frame for the whole 30 s.

    2.8 s run 8.7 MB 30.00 s long

  2. Show the watermark only between two times

    Re-encode
    ffmpeg -i in.mp4 -i logo.png -filter_complex "[1:v]scale=96:-1[logo];[0:v][logo]overlay=W-w-24:H-h-24:enable='between(t,5,15)'" -c:a copy out.mp4

    No logo at 4.9 s, logo at 5.0 s, gone again at 15.1 s. The rest of the frame is the same as the corner command.

    2.8 s run 8.7 MB 30.00 s long

  3. Watermark an image

    Re-encode
    ffmpeg -i photo.jpg -i logo.png -filter_complex "[1:v]scale=96:-1[logo];[0:v][logo]overlay=W-w-24:H-h-24" -q:v 2 out.jpg

    A 1280x546 JPEG with the logo in the corner. -q:v 2 keeps it close to the input's 126 KB.

    82 ms run 126 KB

  4. Add a text watermark

    Re-encode
    ffmpeg -i in.mp4 -vf "drawtext=fontfile=Inter.ttf:text='rendobar.com':fontsize=28:fontcolor=white@0.7:x=w-tw-24:y=h-th-24" -c:a copy out.mp4

    The text in the bottom-right corner at 70% opacity. tw and th are the text size. More text options on Add text to a video.

    2.8 s run 8.7 MB 30.00 s long

  5. Watermark without losing quality

    Re-encode
    ffmpeg -i in.mp4 -i logo.png -filter_complex "[1:v]scale=96:-1[logo];[0:v][logo]overlay=W-w-24:H-h-24" -c:v libx264 -crf 18 -preset slow -c:a copy out.mp4

    13.7 MB against 8.7 MB for the default settings and 12.4 MB for the input. A lower -crf keeps more detail and makes a bigger file.

    5.3 s run 13.7 MB 30.00 s long

Gotchas

Where it goes wrong

Why does overlay fail with Invalid argument under -vf?

-vf builds a filter graph with one input, the video it is attached to, and overlay needs two. Adding -i logo.png does not help, because -vf cannot see the second input. Every image watermark on this page uses -filter_complex with [0:v] and [1:v] labels for that reason.

Why FFmpeg overlay fails under -vf traces the failed watermark jobs behind that error and when drawtext is the right fit for -vf.

Why does FFmpeg never finish when I add -loop 1 to the logo?

A PNG input is one frame. overlay repeats the last frame of the logo until the video ends, so a still logo needs no -loop at all. With -loop 1 the logo becomes an endless stream and overlay keeps going after the video runs out:

ffmpeg -i in.mp4 -loop 1 -i logo.png -filter_complex "[1:v]scale=96:-1[logo];[0:v][logo]overlay=W-w-24:H-h-24" -c:a copy -t 45 out.mp4

Capped with -t 45, the output held 45.0 s of video (1080 frames) for a 30 s input. The last 15 s are one frozen frame. Without the cap the run does not end.

You need -loop 1 when the logo has to change over time, as in a fade. Then add shortest=1 to overlay so it stops with the video. That command came out at 30.0 s and 720 frames.

How do I make the watermark semi-transparent?

Scale the alpha channel of the logo with colorchannelmixer=aa=0.5 and put format=rgba in front of it. format=rgba makes sure there is an alpha channel to scale. A PNG with transparency already has one. A JPEG does not, and without format=rgba the aa setting is ignored: the logo came out fully opaque on a solid black square (left crop above).

overlay=...:alpha=0.5 is not an opacity setting. FFmpeg 8.0 accepts it without a warning, and the frame came out identical to one without it.

A JPEG logo also has no transparent background. If the background is one flat colour, cut it out with colorkey before fading:

ffmpeg -i in.mp4 -i logo.jpg -filter_complex "[1:v]scale=192:-1,colorkey=black:0.2,colorchannelmixer=aa=0.5[logo];[0:v][logo]overlay=W-w-24:H-h-24" -c:a copy out.mp4

The black square is gone and the mark is drawn at 50% opacity, the right crop above. 30.0 s, 720 frames.

How do I scale the logo to the video size? Is scale2ref still the way?

Give scale the video as a second input and use rw and rh, the width and height of that reference: [1:v][0:v]scale=rw/10:-1[logo]. The logo came out 128 px wide on the 1280 px clip and 384 px on a 3840x2160 frame, a tenth of the width both times.

The older scale2ref filter still runs on FFmpeg 8.0 but logs a warning:

ffmpeg -i in.mp4 -i logo.png -filter_complex "[1:v][0:v]scale2ref=w=iw/8:h=ow/mdar[logo][base];[base][logo]overlay=W-w-24:H-h-24" -c:a copy out.mp4

scale2ref is deprecated, use scale=rw:rh instead

Watch for scale=iw*0.1:-1 on the logo input. There iw is the width of the logo, not the video, so the size does not follow the video at all.

Related: Add text to a video, Add subtitles, Resize a video, Stack videos.

Your command. Our infrastructure.

Bring your own commands. Run them on scalable CPU and GPU infrastructure, and pay only for compute time.