Overlay Logo\Watermark on Video

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

T_Minus

Build. Break. Fix. Repeat
Feb 15, 2015
7,625
2,043
113
Would like to place a logo\watermark on a video in a specific location so that it appears throughout the entire video.

Can this be done with an existing python lib?

If so, does it use GPU for acceleration, can it? Does it matter?
 

Blinky 42

Active Member
Aug 6, 2015
615
232
43
48
PA, USA
A few different ways to do it with ffmpeg from the command line - searching for "ffmpeg add watermark" gives a bunch of examples to work with. Decide if you want it to be a logo from an image, or just text from a font and there are lots of options - including transparency / alpha channel blending into the video, or you can give it an embossed look on the video based on your image/font by taking the detected edges on the overlay and blending it.

By default it does it all in software, but depending on the hardware you have to work with and what GPU support is compiled in you can have the gpu assist in decode/encode and possibly the filter to add the overlay. If GPU support helps or not in the grand scheme depends on the video encoding and resolution/bitrate, and the quality you are trying to retain. If processing time isn't a limiting factor, doing it all in software will often give a more pleasing result but YMMV based on the type of content and motion in the scene.

Python or other language wrappers around the core libraries that ffmpeg uses or ffmpeg's internal graph do exist, but unless you are trying to do additional processing on the video / audio in code probably faster to just figure it out on the command line. If you want to do more serious image processing there is OpenCV and other ML / image processing frameworks to work in.

With everything ffmpeg / libav / vlc related, try and get the most recent versions of everything you can to assist in features and speed. The complexity of all the component libraries that each tool uses + the internals of the tools themselves mean there is a lot of development going on for all the pieces and the whole ends up being a fast moving target. If not a one-off job, it can be helpful to compile the whole stack from scratch to get the most recent versions of everything.
 
  • Like
Reactions: T_Minus

T_Minus

Build. Break. Fix. Repeat
Feb 15, 2015
7,625
2,043
113
A few different ways to do it with ffmpeg from the command line - searching for "ffmpeg add watermark" gives a bunch of examples to work with. Decide if you want it to be a logo from an image, or just text from a font and there are lots of options - including transparency / alpha channel blending into the video, or you can give it an embossed look on the video based on your image/font by taking the detected edges on the overlay and blending it.

By default it does it all in software, but depending on the hardware you have to work with and what GPU support is compiled in you can have the gpu assist in decode/encode and possibly the filter to add the overlay. If GPU support helps or not in the grand scheme depends on the video encoding and resolution/bitrate, and the quality you are trying to retain. If processing time isn't a limiting factor, doing it all in software will often give a more pleasing result but YMMV based on the type of content and motion in the scene.

Python or other language wrappers around the core libraries that ffmpeg uses or ffmpeg's internal graph do exist, but unless you are trying to do additional processing on the video / audio in code probably faster to just figure it out on the command line. If you want to do more serious image processing there is OpenCV and other ML / image processing frameworks to work in.

With everything ffmpeg / libav / vlc related, try and get the most recent versions of everything you can to assist in features and speed. The complexity of all the component libraries that each tool uses + the internals of the tools themselves mean there is a lot of development going on for all the pieces and the whole ends up being a fast moving target. If not a one-off job, it can be helpful to compile the whole stack from scratch to get the most recent versions of everything.
Thanks for the info, I have additional info I was able to get with your feedback that may change your suggestions\thoughts too :) I don't do anything with videos so not familiar with any options thus the questions :D and thoughts on best approach CPU\GPU and libs :)

  • It will always be a PNG w\transparency we want to overlay
  • It is not one-off but something I'm building into a work-flow for a buddy with a web GUI so we will be providing video, png, and then storing the created\output video file for their usage. No one will be typing via CLI etc.
  • The process could just be CPU but could also be GPU if it mattered as we have latest-gen GPU available
  • Video will be small clips 99% 1 minute max (longer may be 2M but super-rare nothing LONG)
  • They will be edited videos not raw, h.265 and would obv. like output video to be the same
  • The video-process for this will be on its own VM
Something else that popped into my head while writing this is I'm also looking for an exif\metadata extractor for videos too, I've done this a lot over the years for images and believe we can get a data from videos too. Google gives me a lot of options for videos in various languages, anything you prefer and why?