How to Add a Watermark to a Video using Python?

As a video processing technique, watermarking involves overlaying an image, text, or logo onto a video. There are a bunch of reasons why you'd do this, including branding, adding captions, or inserting overlays to videos. With Python, you can add a watermark to a video using a video editing API. The following Python code shows you how to do this in just a few lines of code:

Input Code
import requests

json = {
 'source': {
  'output_format': 'mp4',
  'elements': [
    'type': 'video',
    'source': ''
    'type': 'image',
    'source': '',
    'x': '100%',
    'y': '0%',
    'width': '60 vmin',
    'height': '60 vmin',
    'x_padding': '7 vmin',
    'y_padding': '7 vmin',
    'x_anchor': '100%',
    'y_anchor': '0%',
    'x_alignment': '100%',
    'y_alignment': '0%',
    'shadow_color': 'rgba(0,0,0,0.66)',
    'fit': 'contain'

response =
  # Find your API key under 'Project Settings' in your account:
  'Authorization': 'Bearer Your-API-Key',
  'Content-Type': 'application/json',

# Wait a minute, then visit the URL provided in the response:

Output Video

How it works: All that is required is the "requests" library that comes pre-installed with every Python installation. In this example, we've got two main components: a background video and a watermark image that goes on top of it. You can use any video or image file, as long as it's accessible through a public URL.

The watermark image, like a logo, sits in the top-right corner of the scene. We do this by specifying the "x" and "y" properties, along with the "x_anchor" and "y_anchor" properties. And to give some space between the logo and the video edges, we use the "padding" property.

In this case, all properties are defined in terms of relative units, such as "vmin" and "%". This makes sure that the overlay adjusts dynamically to the background video, working well with different video formats, whether they're horizontal, vertical, or square.

Try out your own overlay with the online video editor below. This online tool lets you create custom video layouts and export them as JSON for easy integration into your Python applications. Use it for all of your Python video editing needs.

Edit this Code Example in the Video Editor

Easily design your own video templates using the online editor. Then, export your templates as JSON and integrate them into your Python application to create any kind of video – completely through code.

Related Python Video Editing Questions

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free