Add a logo watermark to a video
// what it does
Overlays a logo sized relative to the video. split makes a reference copy [ref] of the main video so scale can size the logo against it — scale=rw/10:-1 sets the logo to one-tenth of the reference (video) width with -1 preserving aspect ratio. overlay=W-w-W*0.02:H*0.02 then composites it where W/H are the base video's dimensions and w is the logo width, placing it in the top-right corner with a 2% margin.
// shell
$ ffmpeg -i input.mp4 -i logo.png -filter_complex "[0:v]split[base][ref];[1:v][ref]scale=rw/10:-1[logo];[base][logo]overlay=W-w-W*0.02:H*0.02" output.mp4// gotcha
In overlay expressions W/H mean the base frame and w/h the logo, so swapping them mispositions the mark. And scale=rw/10 only sizes against the video because [ref] gives scale a reference input (the merged scale2ref behavior, FFmpeg 7.1+) — older builds need the standalone scale2ref filter, which also emits a passthrough output you must consume. The -1 auto-height is fine here even if it comes out odd: the encoded frame keeps the base video's (even) dimensions, so libx264/yuv420p won't reject it.