MCP tool for video shake detection using ffmpeg vidstabdetect (requires ffmpeg with libvidstab). Generates a .trf analysis file and writes a stabilize directive to OTIO timeline metadata for use with clipwright-render.
Project description
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=nullwhen the file cannot be parsed (non-fatal; render does not use severity).
Prerequisites
- Python 3.11 or later
- ffmpeg compiled with
--enable-libvidstabmust exist on PATH or full path set in environment variableCLIPWRIGHT_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
- detect (this tool):
ffmpeg -i <media> -vf "vidstabdetect=result=<stem>.stabilize.trf:shakiness=<n>:accuracy=<n>" -f null -generates.trfand saves the stabilize directive to OTIO annotation. - render (clipwright-render): reads
metadata["clipwright"]["stabilize"]and appliesvidstabtransform=input=<basename>:smoothing=<n>in the ffmpeg filter graph usingcwd=<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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clipwright_stabilize-0.1.0.tar.gz.
File metadata
- Download URL: clipwright_stabilize-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c6c318cec738f156a941856f4487b6993156f6419b18650c4f8434247a640b1
|
|
| MD5 |
0241c0dc0f0696f17b42c567d2d13a10
|
|
| BLAKE2b-256 |
d84741bf52b2e16e9402d572c0f63904beb051de9292eff22f3b01de39ea3739
|
Provenance
The following attestation bundles were made for clipwright_stabilize-0.1.0.tar.gz:
Publisher:
publish.yml on satoh-y-0323/clipwright
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clipwright_stabilize-0.1.0.tar.gz -
Subject digest:
0c6c318cec738f156a941856f4487b6993156f6419b18650c4f8434247a640b1 - Sigstore transparency entry: 1859915015
- Sigstore integration time:
-
Permalink:
satoh-y-0323/clipwright@27475145e3d26ed019ad056a49d4cdcdce465f67 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/satoh-y-0323
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@27475145e3d26ed019ad056a49d4cdcdce465f67 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clipwright_stabilize-0.1.0-py3-none-any.whl.
File metadata
- Download URL: clipwright_stabilize-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e7ae343b561d66540948de6396d26287f65b8c0fffac61598f980c3b0ccf4de
|
|
| MD5 |
7085688379ca03e67240d5c4f3610630
|
|
| BLAKE2b-256 |
a6df11e0ce4dccaf5a8fea9470914bc805f19a4430d00a1e31931a743ac54d78
|
Provenance
The following attestation bundles were made for clipwright_stabilize-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on satoh-y-0323/clipwright
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clipwright_stabilize-0.1.0-py3-none-any.whl -
Subject digest:
9e7ae343b561d66540948de6396d26287f65b8c0fffac61598f980c3b0ccf4de - Sigstore transparency entry: 1859915047
- Sigstore integration time:
-
Permalink:
satoh-y-0323/clipwright@27475145e3d26ed019ad056a49d4cdcdce465f67 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/satoh-y-0323
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@27475145e3d26ed019ad056a49d4cdcdce465f67 -
Trigger Event:
push
-
Statement type: