Add Watermark to Top Right of Video with FFmpeg
This guide provides a straightforward tutorial on how to position an
image watermark in the top-right corner of a video using the FFmpeg
overlay filter. You will learn the exact command-line
syntax, understand how the coordinate system works, and see practical
examples to customize the watermark’s padding.
To place a watermark in the top-right corner, you must calculate the
horizontal (x) and vertical (y) coordinates
using FFmpeg’s built-in variables.
The Coordinate Formula
- Horizontal Position (
x):main_w - overlay_w(Video width minus watermark width) - Vertical Position (
y):0(The very top of the video)
By subtracting the width of the watermark from the width of the video, the image is pushed to the far right edge. Setting the vertical coordinate to zero aligns it with the top edge.
Basic Command
Use the following command to place the watermark flush against the top-right corner:
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=main_w-overlay_w:0" output.mp4Command with Padding (Recommended)
In most cases, placing a watermark directly against the edge looks crowded. You can add padding (for example, 20 pixels of space from both the top and right edges) by adjusting the math:
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=main_w-overlay_w-20:20" output.mp4Parameter Breakdown
-i input.mp4: Specifies the main video file as the first input.-i watermark.png: Specifies the watermark image (PNG is recommended for transparency support) as the second input.-filter_complex: Invokes the filtergraph.overlay=: The filter used to stack the second input on top of the first.main_w(orW): The width of the main video.overlay_w(orw): The width of the watermark image.-20: Subtracts 20 pixels from the right-most edge to create a margin.:20: Sets the vertical position (y) to 20 pixels down from the top edge.
output.mp4: The name of the newly generated video file.