MCP tool for video brightness detection and OTIO timeline color annotation generation. Measures average luma with ffmpeg signalstats and writes an eq color-correction directive to timeline-level metadata.
Project description
clipwright-color
MCP tool for video brightness detection and OTIO timeline color annotation generation.
Overview
Measures average luma using the ffmpeg signalstats filter,
writes a color correction directive (brightness offset, eq parameters) to timeline-level
metadata["clipwright"]["color"].
Performs detection only (OTIO annotation); realization (eq filter application) is done once
by clipwright-render (design M3: separation of detection and application).
Brightness derivation:
- Samples frames at a configurable interval using
fps=1/<interval>andsignalstats=stat=brng. - Computes mean luma (YAVG) across sampled frames.
- Derives brightness offset as
clamp((target_luma - YAVG) / 255.0, -1.0, 1.0). - Contrast, saturation, and gamma are left at neutral defaults (1.0 / 1.0 / 1.0); only brightness is auto-derived from the measured luma.
Prerequisites
- Python 3.11 or later
- ffmpeg must exist on PATH or full path set in environment variable
CLIPWRIGHT_FFMPEG.
export CLIPWRIGHT_FFMPEG=/path/to/ffmpeg
export CLIPWRIGHT_FFPROBE=/path/to/ffprobe
MCP Tool
clipwright_detect_color
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.target_luma |
float |
128.0 |
Target average luma on the 0-255 scale (default: mid-grey) |
options.sample_interval_sec |
float |
1.0 |
Frame sampling interval in seconds (ffmpeg fps=1/interval, must be > 0) |
timeline |
string | null |
null |
Existing OTIO timeline path (if specified, append color directive to it) |
Return value
The tool returns a ToolResult envelope:
{
"ok": true,
"summary": "Color analysis complete. measured_luma=96.4 ...",
"data": {
"measured_luma": 96.4,
"brightness": 0.123,
"contrast": 1.0,
"saturation": 1.0,
"gamma": 1.0,
"target_luma": 128.0,
"sampled_frames": 12
},
"artifacts": [{"role": "timeline", "path": "out.otio", "format": "otio"}],
"warnings": []
}
When measurement is not possible (measured=None, U-1), the color directive is not written
but the timeline is still saved and a warning is returned.
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 "fps=1/1,signalstats=stat=brng,metadata=print" -f null -extracts per-frame YAVG and saves the derived eq directive to OTIO annotation. - render (clipwright-render): reads
metadata["clipwright"]["color"]["eq"]and applieseq=brightness=...:contrast=...:saturation=...:gamma=...in the ffmpeg filter graph.
Installation and Startup
Within a uv workspace:
uv run --package clipwright-color clipwright-color
Or install directly:
uv add clipwright-color
clipwright-color
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_color-0.1.0.tar.gz.
File metadata
- Download URL: clipwright_color-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6da20d4ef9ae561d011af3e73e2c152086005b91a354fd1770092dfe5e9b0e7
|
|
| MD5 |
7a2338a544c9729b352bf8fa2c2e4dc5
|
|
| BLAKE2b-256 |
f0e23b322540d7792da3e25dea56493b784de66510b9be221590b3a273a2fd7c
|
Provenance
The following attestation bundles were made for clipwright_color-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_color-0.1.0.tar.gz -
Subject digest:
b6da20d4ef9ae561d011af3e73e2c152086005b91a354fd1770092dfe5e9b0e7 - Sigstore transparency entry: 1859644633
- Sigstore integration time:
-
Permalink:
satoh-y-0323/clipwright@df57ce2beeb6b8ca6823ed35f5dd55b7a8fc25e5 -
Branch / Tag:
refs/tags/v0.7.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@df57ce2beeb6b8ca6823ed35f5dd55b7a8fc25e5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clipwright_color-0.1.0-py3-none-any.whl.
File metadata
- Download URL: clipwright_color-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 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 |
4dcd8800275a538b9acb3f42abb5f764f00903daadade97d166c0acfe545ff66
|
|
| MD5 |
4c10eb10d3e4bef60dfe80e6dccba324
|
|
| BLAKE2b-256 |
1c56a08fb5dfe9cbaffd06945e6f2e670868bfa968c695bce13c2b103f75e42a
|
Provenance
The following attestation bundles were made for clipwright_color-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_color-0.1.0-py3-none-any.whl -
Subject digest:
4dcd8800275a538b9acb3f42abb5f764f00903daadade97d166c0acfe545ff66 - Sigstore transparency entry: 1859644647
- Sigstore integration time:
-
Permalink:
satoh-y-0323/clipwright@df57ce2beeb6b8ca6823ed35f5dd55b7a8fc25e5 -
Branch / Tag:
refs/tags/v0.7.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@df57ce2beeb6b8ca6823ed35f5dd55b7a8fc25e5 -
Trigger Event:
push
-
Statement type: