Skip to main content

mediakit

One CLI, 17 commands, JSON out — for agents that need to watch, listen, subtitle and cut.

mediakit is a thin orchestration layer over mature media tools. It does not reimplement decoding, ASR or scene detection; it calls them and returns structured results an agent can reason about, plus an MCP server so the whole toolkit can be attached to any MCP client.

$ mk watch clip.mp4 --out work/clip --lang zh --ocr
语言 zh · 4 镜头 · 12 关键帧 · 转写 8 段 · 画面文字 2 条
$ mk search work/clip/index "穿黑裙子的女孩在草地上" --top 3
   42.50s  score 0.311  ...

中文说明

Why another wrapper?

Most tools are excellent at one step and then stop: PySceneDetect prints a table, Whisper emits one long line, CLIP libraries return tensors. An agent needs the opposite: short, composable commands with stable JSON, and no GUI.

Upstream What it does What mk adds
PySceneDetect shot boundaries contact.jpg, shots.json, OTIO export
faster-whisper segments + words pause-based line breaking, width limits, 繁→简, karaoke, QA
ffmpeg encode/cut/burn one plan file, xfade + acrossfade, subtitle rescaling
RapidOCR text boxes frame sampling, de-dup, SRT output
CLIP embeddings index/search commands with thumbnails
librosa tempo/beats tempogram tempo prior, sections, chords, melody
VideoCaptioner LLM subtitle polish one command, local Ollama, bilingual output

Install

pip install "mediakit-cli[all]"     # everything
pip install mediakit-cli            # core only: probe, edit, auto, plan logic

ffmpeg must be on PATH (or set MEDIAKIT_FFMPEG). Optional groups:

The distribution is named mediakit-cli; the Python import package is mediakit_cli (to avoid a collision with the unrelated PyPI package mediakit). The CLI command is mk either way.

Extra Enables Install
asr subs, watch, lyrics faster-whisper
vision shots, shotcard, ocr OpenCV, PySceneDetect, RapidOCR
music music librosa
search index, search open_clip + ViT-B-32 weights
separate lyrics --separate audio-separator
mcp mediakit-mcp MCP SDK
windows dub, voices pywin32 + SAPI
timeline shots --otio OpenTimelineIO

Environment overrides: MEDIAKIT_FFMPEG, MEDIAKIT_AUDIO_SEPARATOR, MEDIAKIT_VIDEOCAPTIONER, MEDIAKIT_OLLAMA_BASE, MEDIAKIT_VLM_MODEL.

Commands

# look
mk probe    a.mp4
mk watch    a.mp4 --out work/a --lang zh --ocr
mk frames   a.mp4 --n 12 --out work/a/frames
mk ocr      a.mp4 --out work/a/ocr --every 2
mk index    a.mp4 --out work/a/index
mk search   work/a/index "a girl running on grass"

# listen
mk music    song.mp3 --chords --melody --engine beat-this
mk lyrics   song.mp3 --out work/lyrics --lang ja

# dissect
mk shots    a.mp4 --out work/a --otio
mk shotcard a.mp4 --out work/a/card --vlm

# subtitle
mk subs     a.mp4 --lang zh --out work/a --size 1080x1920 --max-chars 12 --karaoke --qa
mk subqa    work/a/subs.srt
mk polish   work/a/subs.srt --out work/a/polished.srt
mk voices
mk dub      a.mp4 --srt work/a/subs.srt --out work/dub.mp4 --voice Huihui --mix-original

# cut
mk edit     work/plan.json --out work/final.mp4
mk auto     --music bgm.mp3 --src footage --out work/mv.mp4 --transition fade

Every command accepts --json. Without it you get a short human summary.

mk auto — beat-synced montage

Analyzes the track, decides how many beats per cut per section (quiet sections get longer cuts, loud ones shorter), picks shots from a folder, snaps cuts to beats and renders xfade transitions with matching acrossfade audio.

mk auto --music bgm.mp3 --src footage --out mv.mp4 \
        --size 1080x1920 --fit crop --transition fade --seed 7
mk auto --music bgm.mp3 --src footage --out mv.mp4 --plan-only   # plan only

MCP server

{
  "mcpServers": {
    "mediakit": { "command": "mediakit-mcp" }
  }
}

12 tools: probe, shots, music, subs, ocr, shotcard, index, search, lyrics, dub, edit, auto.

Measured, not assumed

Numbers below were produced on a local machine (CPU) with the benchmark scripts in tools/. They are small-sample results, not leaderboard claims.

Area Result
Shot detection 3 hard cuts detected at exactly 4.00s / 8.00s
Subtitles 16.5s Chinese speech → 9 lines, traditional→simplified, width capped
Karaoke \kf per word; at 0.2s 65% of subtitle pixels still unsung color
OCR read burned subtitles back as 「大家晚上好。」and merged into SRT
Retrieval (synthetic, 8 segments) recall@1 75% descriptive / 88% short, recall@3 100%
Retrieval (real footage, 8 clips) recall@1 75%, recall@3 100%
Lyric CER vs reference subs mix 89.7% → vocals 60.3% (small) → 54.4% (medium)
Tempo correction librosa default 103.36 BPM was a 4:3 artifact; tempogram prior → 80.75 BPM
Montage 7 segments from a 20s track; 18.50s with 6×0.25s fades
Audio crossfade 3×2s clips + 0.25s fade + keep_audio → 5.50s, audio kept
Dubbing 9 lines → 18.60s output, full length, 2ch/48kHz

Known limits

  • Retrieval benchmarks are small (8 segments/clips) and CLIP is phrasing-sensitive; low-information frames (pure white/black) fail.
  • Singing transcription is still hard: 54% CER is the good case.
  • dub uses Windows SAPI — robotic, and long lines are time-compressed at most 2×.
  • VLM shot descriptions were validated on a handful of frames.
  • beat_this and librosa often disagree by a few BPM; the package now anchors tempo with a tempogram prior but does not prove which tracker is musically right.
  • Transition handling assumes hard cuts when detecting shots.

Layout

mediakit_cli/        package (17 modules + MCP server)
tools/           benchmarks: retrieval, lyrics CER, tempo
docs/            architecture and data contracts
examples/        sample edit plan
tests/           unit tests for pure logic

License

MIT

Metadata

Release files for mediakit-cli 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mediakit-cli 0.1.2
File Size Uploaded Provenance Actions
mediakit_cli-0.1.2.tar.gz 45.4 kB Without provenance Details for mediakit_cli-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mediakit-cli 0.1.2
File Interpreter ABI Platform Actions
mediakit_cli-0.1.2-py3-none-any.whl Python 3 none any Details for mediakit_cli-0.1.2-py3-none-any.whl

Total release size: 93.0 kB

Release files / mediakit_cli-0.1.2.tar.gz

Download URL mediakit_cli-0.1.2.tar.gz
Size 45.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a32627a23da2028c8f172f05a7c2b21af019e2f580f6601579c089078d46601b
BLAKE2b-256 checksum
How to use checksums
1224ef1a88abba9630ec3b89f62562476a9eeb60170b331aecf2a951862d8204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / mediakit_cli-0.1.2-py3-none-any.whl

Download URL mediakit_cli-0.1.2-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60f18dd8ab1566d8df7da0466fc2ef7d366ac148db0f4cc3a48606afd4dccffc
BLAKE2b-256 checksum
How to use checksums
a3a004340c77418fd9de6f3b814faa0c79a84b087c203f17b452bc1accf46986
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for mediakit-cli 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page