I couldn't figure out how to set the coordinates of a logo to be added on a video.
On the Internet I found the following commands:
1) Add logo to the "Bottom left corner"
ffmpeg –i inputvideo.mp4 -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" outputvideo.mp4
2) Add logo to the "Bottom right corner"
ffmpeg –i inputvideo.mp4 -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=(main_w-overlay_w-10)/2:(main_h-overlay_h-10)/2 [out]" outputvideo.mp4
Could you please help me understand the overlay settings?
Best Answer
The
overlay
filter takes two arguments: the x and y position of the top left corner of the image.In this command:
The top left x position is 10, and the top left y position is determined by the “outer” / main image's height
main_h
and the height of the overlaid image (overlay_h
), then additionally subtracting 10 pixels to add a little space from the edge.If you're unsure what these coordinates mean or how to determine them, perhaps you need to draw them on a sheet of paper.
You can use the
scale
filter:Here, the second input video (
1:v
) is scaled to 200⨉100 pixels and then labeled as1v
. It's then used in theoverlay
filter.That depends on your application, but generally you need to know your input video size and the size of the logo. FFmpeg cannot guess where to place the logo for you. If you want to place it somewhere in the corner, the given examples should however suffice, assuming that the logo is not too big.