Automatically detect and remove watermarks from videos using AI inpainting.
- Detection: Temporal variance analysis identifies static overlay regions (watermarks). Falls back to YOLOv8n watermark detector if variance analysis fails.
- Inpainting: LaMa (Large Mask Inpainting) fills in detected regions frame-by-frame.
- Encoding: FFmpeg pipe-based I/O keeps memory usage constant regardless of video length.
- Python 3.9+
- FFmpeg installed and on PATH
pip install -r requirements.txtpython dewatermark.py -i input.mp4 -o output.mp4python dewatermark.py -i input.mp4 -o output.mp4 -m mask.pngpython dewatermark.py -i input.mp4 -o output.mp4 --region 50,20,200,60| Flag | Default | Description |
|---|---|---|
-i |
required | Input video path |
-o |
required | Output video path |
-m |
— | Mask image (white = watermark) |
--region |
— | Bounding box as X,Y,W,H |
--model-dir |
~/.cache/dewatermark |
Model download directory |
--feather |
5 | Gaussian blur on mask edges (px) |
--crf |
18 | Output quality (lower = better) |
--preset |
medium | FFmpeg encoding preset |
--sample-frames |
30 | Frames for variance analysis |
--variance-threshold |
auto | Variance sensitivity (0-1, default: Otsu) |
Models are downloaded automatically on first run:
- LaMa (Carve/LaMa-ONNX) — ~208MB, inpainting
- YOLOv8n (qfisch/yolov8n-watermark-detection) — ~12MB, watermark detection (fallback only)