Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg scale2ref explanation?

Tags:

ffmpeg

I'm applying a watermark to a video. I'm trying to get the watermark to scale proportionally to the video dimensions. I've seen maybe a dozen different answers using scale2ref, but no explanations as to actually what's happening, so I'm finding it difficult to know how to implement/make changes to the configs to work for my situation.

Current overlay command:

ffmpeg -i test.mp4 -i logo.png -filter_complex "overlay=0:0" output.mp4

Some answers I've looked at:

ffmpeg creating gif from images, add watermark during creation?

ffmpeg fix watermark size or percentage

What are the rules to how scale2ref works?

like image 489
Geuis Avatar asked Jul 27 '17 22:07

Geuis


People also ask

What is overlay FFmpeg?

FFmpeg offers the overlay filter as a way to overlay images (or even other videos) onto video streams. To centre overlay/watermark on a video, use this command: ffmpeg -i inputvideo.avi -i watermarklogo.png -filter_complex \ "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy output.flv.

What can FFmpeg do?

ffmpeg is a command-line tool that converts audio or video formats. It can also capture and encode in real-time from various hardware and software sources such as a TV capture card. ffplay is a simple media player utilizing SDL and the FFmpeg libraries.


1 Answers

Apply this filter to position the watermark

Center:
overlay=(main_w-w)/2:(main_h-h)/2
Top left corner:
overlay=1:1
Top right corner:
overlay=W-w-1:1
lower right corner:
overlay=W-w-1:H-h-1
Bottom left corner:
overlay=1:H-h-1
Bottom right corner. Padding 10px to the right and -10px to the bottom:
overlay=main_w-w/1:main_h-h/2
Bottom right corner. Padding -10px to the right and -10px to the bottom:
overlay=main_w-w/1:main_h-h/2

Center:
-filter_complex "overlay=(main_w-w)/2:(main_h-h)/2" -preset ultrafast -codec:a copy

like image 173
Artem Avatar answered Sep 16 '22 23:09

Artem