Skip to main content

clipwright-stabilize

MCP tool for video shake detection and OTIO timeline stabilize annotation generation.

Overview

Runs ffmpeg vidstabdetect to generate a .trf transform file, estimates shake severity from the binary TRF1 data (best-effort heuristic), and writes a stabilize directive to timeline-level metadata["clipwright"]["stabilize"].

Performs detection only (OTIO annotation); realization (vidstabtransform application) is done once by clipwright-render (design M3: separation of detection and application).

Severity estimation:

  • Reads the binary TRF1 file produced by vidstabdetect.
  • Scans all IEEE-754 little-endian doubles, computes mean absolute value.
  • Normalises by a pinned heuristic constant (_NORM_PX = 30.0 px) to derive a severity in [0.0, 1.0].
  • Returns severity=null when the file cannot be parsed (non-fatal; render does not use severity).

Prerequisites

  • Python 3.11 or later
  • ffmpeg compiled with --enable-libvidstab must exist on PATH or full path set in environment variable CLIPWRIGHT_FFMPEG. Standard distribution builds (apt, brew, choco) may NOT include libvidstab. Use a build that explicitly enables the vidstab filter.
export CLIPWRIGHT_FFMPEG=/path/to/ffmpeg-with-libvidstab
export CLIPWRIGHT_FFPROBE=/path/to/ffprobe

MCP Tool

clipwright_detect_shake

Parameters

Name Type Default Description
media string required Input video file path (video stream required)
output string required Output OTIO timeline path (.otio, same directory as media)
options.shakiness int 5 vidstabdetect shakiness 1-10 (higher = assume more shake)
options.accuracy int 15 vidstabdetect accuracy 1-15 (higher = more accurate / slower)
options.smoothing int 30 vidstabtransform smoothing window in frames 0-1000
timeline string | null null Existing OTIO timeline path (if specified, append stabilize directive)

Return value

The tool returns a ToolResult envelope:

{
  "ok": true,
  "summary": "Shake analysis of video.mp4 complete. severity=0.312, shakiness=5, smoothing=30. Stabilize directive and video.stabilize.trf written; apply with clipwright-render.",
  "data": {
    "severity": 0.312,
    "shakiness": 5,
    "accuracy": 15,
    "smoothing": 30,
    "trf_basename": "video.stabilize.trf"
  },
  "artifacts": [
    {"role": "timeline", "path": "out.otio", "format": "otio"},
    {"role": "analysis", "path": "video.stabilize.trf", "format": "trf"}
  ],
  "warnings": []
}

When libvidstab is not compiled into the ffmpeg build, the tool returns UNSUPPORTED_OPERATION with installation guidance (no path or raw stderr exposed).

Dependencies

Package Purpose
clipwright Shared types, envelope, errors, process.run
mcp[cli] MCP server
pydantic Parameter validation

ffmpeg is invoked as a separate process (via PATH or environment variable) for license independence.

Detection and Render Two-Phase Flow

  1. detect (this tool): ffmpeg -i <media> -vf "vidstabdetect=result=<stem>.stabilize.trf:shakiness=<n>:accuracy=<n>" -f null - generates .trf and saves the stabilize directive to OTIO annotation.
  2. render (clipwright-render): reads metadata["clipwright"]["stabilize"] and applies vidstabtransform=input=<basename>:smoothing=<n> in the ffmpeg filter graph using cwd=<trf parent directory> for Windows-safe relative path resolution.

Installation and Startup

Within a uv workspace:

uv run --package clipwright-stabilize clipwright-stabilize

Or install directly:

uv add clipwright-stabilize
clipwright-stabilize

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clipwright_stabilize-0.5.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clipwright_stabilize-0.5.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file clipwright_stabilize-0.5.0.tar.gz.

File metadata

  • Download URL: clipwright_stabilize-0.5.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for clipwright_stabilize-0.5.0.tar.gz
Algorithm Hash digest
SHA256 879187bfb3c39c1dd4e9a24e9c6fcf4db0700cd1e076294171a858b839cdd663
MD5 7a08e0fa9135d26a7b67d7d54ce6a6ec
BLAKE2b-256 36bd9369b9afa3e4c41259363dad5fd236fe8c9ed6f24b905b40358e45219afb

See more details on using hashes here.

Provenance

The following attestation bundles were made for clipwright_stabilize-0.5.0.tar.gz:

Publisher: publish.yml on satoh-y-0323/clipwright

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clipwright_stabilize-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for clipwright_stabilize-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7efea3cd9a643b30d13aab409ce4eb38da981a054edd5c0a4aa52f1f2129a8d
MD5 0f44249f3b9baedebd1b864f2410310c
BLAKE2b-256 b73017165d451d00c2ed428ac27f34b82cbe75de64295c2a9afdb76c242eb43b

See more details on using hashes here.

Provenance

The following attestation bundles were made for clipwright_stabilize-0.5.0-py3-none-any.whl:

Publisher: publish.yml on satoh-y-0323/clipwright

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page