dsh-tool-video-watermark: Removing Static Semi-Transparent Watermarks via Alpha Unblending

Introduction

The DeepSeek Harness (DSH) plugin ecosystem supports a wide range of tasks, but video watermark removal has always been a pain point. Traditional approaches like delogo or cv2.inpaint tend to flatten or blur the watermark region, resulting in loss of detail. The DSH plugin l0li0n/dsh-tool-video-watermark takes a mathematical approach by treating the watermark as a transparent overlay layer. It estimates the opacity and overlay color, then algebraically recovers the background — avoiding blur or patch artifacts — and provides objective verification metrics.

Plugin Scope

This is a DSH tool plugin developed by the maintainer L0LI0N, categorized under “Fun Reskin.” Its core value is: removing static semi-transparent watermarks via an Alpha unblending algorithm, with quantitative verification results.

Core Features

  • Static semi-transparent watermark removal: Handles fixed-position, semi-transparent watermarks such as logos, channel corner badges, and username tags.
  • Alpha unblending: Based on the formula obs = alpha * W + (1 - alpha) * bg, estimates the watermark’s opacity alpha and overlay color W, then algebraically reconstructs the background to avoid blurring.
  • Auto-detection & scanning: Uses watermark_scan to detect watermark position and approximate opacity across multiple frames, with heatmap generation support.
  • Multiple tool chains: watermark_doctor checks the environment; watermark_scan scans for watermarks; watermark_remove renders the cleaned video; watermark_verify scores the result.
  • Objective verification: Compares metrics such as contrast between the watermark region and its surroundings, residual ratio, low-frequency artifacts, and chromatic dispersion to judge removal quality.

Installation & Setup

Environment Requirements

  • Node 20+
  • Python 3.10+
  • ffmpeg, available on PATH
  • numpy, OpenCV (Python-side dependencies)

Installing Dependencies

python -m pip install -r python/requirements.txt

Loading from Source (Development/Debugging)

pnpm dsh web --patch /absolute/path/to/dsh-tool-video-watermark/cordis.yml

Note: The path must be an absolute path. Relative paths will silently fail, and the plugin will not be loaded.

Packaging & Installing to a Profile

npm pack                     # generates dsh-tool-video-watermark-0.1.0.tgz
dsh plugin --profile default add ./dsh-tool-video-watermark-0.1.0.tgz
dsh --profile default --dump-config | grep video-watermark

Configuration Options

All configuration items below are optional with the following defaults:

Key Default Description
pythonPath auto Python interpreter that can import numpy and cv2
ffmpegPath PATH Path to the ffmpeg binary
timeoutMinutes 45 Maximum time limit per run (~4–6 min per minute of footage at 1080p)
defaultCrf 18 x264 quality parameter, used when the caller does not specify crf
verbose false Log per-stage progress to the Harness log

Workflow

A typical pipeline is as follows:

  1. Detection: Across multiple frames, the watermark contributes a fixed high-frequency component, while scene texture varies sign with content. Scoring via the ratio of mean to standard deviation after high-pass filtering distinguishes the watermark region from the rest.
  2. Background field estimation: For calibration frames, normalized convolution is applied only on “clean pixels” to obtain a local background estimate L. The TELEA patch algorithm is deliberately avoided, as it would pull in the luminance band at the watermark boundary and corrupt subsequent steps.
  3. Per-pixel fitting: For each pixel, obs = A + d·L, where A = alpha·W and d = 1 - alpha. A global ridge smoothing is applied to the slope to obtain the clip-wide average opacity.
  4. Inversion & regularization: First, bg = (obs - A) / d is computed on the luminance channel, then regularized with the smooth field: bg = L + w * (bg_inverted - L), where w = clip(1 - 1.2*alpha, 0.25, 0.85). In near-opaque regions, w is clamped to 0.25–0.85 to prevent noise amplification. A detail-priority mode can override w.
  5. Chrominance reconstruction: Instead of directly unblending chrominance, a luminance-guided bilateral filter is used for reconstruction, avoiding the amplification of compression noise that would result from dividing by 1 - alpha.
  6. Verification: Checks whether the watermark region’s contrast has dropped to the noise floor, and whether pixel changes outside the region fall within re-encoding noise bounds — judging quality by numbers rather than intuition.

Usage Example

The verification command example from the README:

python python/wm_engine.py verify \
  --input source.mp4 --output cleaned.mp4 --box 26,28,380,110

This command removes a semi-transparent white corner-badge watermark from a 1920×1080, 2429-frame clip. At CRF 18, the full pass takes approximately 3 minutes 42 seconds.

Use Cases & Limitations

  • Use cases: Video content requiring removal of fixed-position, semi-transparent watermarks, especially where detail preservation is critical.
  • Limitations:
  • Only one watermark overlay layer is processed per invocation. Multiple watermarks require separate scanning and processing.
  • The watermark must be static: drifting or animated badges will break the temporal model.
  • Opacity must be identifiable from luminance variation. Locked-off camera shots with uniform lighting may require a manually specified alpha; otherwise the engine will throw an error.
  • Large, centered watermarks (occupying half the frame) will degrade background field estimation due to insufficient clean neighborhood.
  • Removal does not “generate” detail out of thin air: the background is a reconstruction from surrounding information. Dense text overlaid on complex textures will leave smoothed regions.
  • Use only on content you have rights to or are authorized to process.

Ecosystem Context

DSH follows the “everything is a plugin” philosophy. Community directories (such as SkillHub) are independent sites with no official affiliation to DeepSeek or High-Flyer; they serve solely as plugin discovery and showcase platforms.

Summary

dsh-tool-video-watermark is a DSH tool plugin based on Alpha unblending that removes static semi-transparent watermarks via a mathematical model and provides quantitative verification metrics. It is well suited for video de-watermarking scenarios where detail preservation is a priority, but its applicable scope and limitations should be kept in mind.

  • Directory page: https://www.skillhub.cn/plugins/L0LI0N/dsh-tool-video-watermark
  • GitHub: https://github.com/L0LI0N/dsh-tool-video-watermark
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye