HomeDocsPython guide
Python guide · Video

How to Watermark Video in Python

Stop pulling your hair out over Python subprocess calls to FFmpeg. Stamp videos dynamically via a clean REST API.

Writing Python code with API Watermark

The nightmare of FFmpeg + Python

Building a video processing pipeline in Django or FastAPI usually requires installing FFmpeg binaries on your server, writing fragile `subprocess.Popen` commands, and implementing Celery/Redis for background task queuing because video rendering blocks the main thread. It's an infrastructural nightmare. API Watermark replaces all of that with a single async HTTP call.

Step by step

Drop this into your project today

  1. 1

    1. Define your webhook

    Video processing can take several seconds or minutes. Create a simple POST route in your Python app (FastAPI, Flask, Django) to listen for the completion event.

  2. 2

    2. Submit the Video Job

    Use the `requests` library to POST your video URL and watermark configuration to our queue.

  3. 3

    3. Handle the Webhook Callback

    Once our GPUs finish rendering, we'll ping your webhook with the final CDN URL of your branded video.

Async Video Trigger (Python Requests)
import requests
import os

API_KEY = os.getenv("API_WATERMARK_KEY")

def watermark_video(source_url: str, user_id: str):
    payload = {
        "sourceUrl": source_url,
        "outputFormat": "mp4",
        "watermarkConfig": {
          "watermark": {
            "type": "text",
            "text": f"Property of {user_id}",
            "position": "center"
          }
        }
    }

    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    }

    response = requests.post("https://apiwatermark.com/api/video/watermark", json=payload, headers=headers)
    
    if response.status_code == 202:
        job_id = response.json().get("jobId")
        print(f"Job started successfully! ID: {job_id}")
    else:
        print("Failed to start job:", response.text)

watermark_video("s3://raw/video-102.mp4", "Client_994")

FAQ

Developer questions

Can I track the progress of a video job?

+
Yes. Poll `GET /api/video/watermark/{jobId}` with the same API key you used to create the job, then use `?download=1` when the job is complete.

What output formats do you support?

+
By default, videos are encoded in high-compatibility MP4 (H.264). We also support WebM output for modern browser delivery.

Do you support video trim and audio stripping?

+
Yes, you can pass parameters in the API to shorten the video or remove the audio track during the watermarking process.

Watermark video from Python today

Stop maintaining Python media pipelines. Free tier covers 100 calls a month.