ClipForge
README.md
# ClipForge
A video editor that Claude drives through tools — our own take on what Filmora offers, built for
being operated by an AI. The timeline lives in a readable JSON file (`*.clipforge.json`); rendering
is done by ffmpeg; speech recognition and background removal run locally (whisper.cpp and Apple
Vision). Nothing here copies Filmora code — Filmora was only studied (via REA) to decide which
features and workflows matter.
**53 tools** · MCP server + CLI · live browser preview · no cloud · `npm test` runs 3 test groups.
## Use it from Claude
Requirements: macOS, Node.js 20 or newer (tested with 22) and `ffmpeg` (`brew install ffmpeg`).
```bash
git clone https://github.com/ThorstenKoerth/clipforge.git
cd clipforge
npm install
```
Register once (run inside the `clipforge` folder):
```bash
claude mcp add clipforge -- node "$(pwd)/src/cli.js" mcp
```
Then ask Claude things like “cut the pauses out of interview.mp4, add a lower-third for Anna and
export a 9:16 version”. Claude checks its own work with `contact_sheet` / `preview_frame`
(PNG it can look at) before exporting.
## Teach Claude the workflow
`.claude/skills/clipforge/SKILL.md` is a Claude Code skill (workflow, recipes, pitfalls) that loads
automatically when Claude runs in this folder. To use it everywhere:
`cp -R .claude/skills/clipforge ~/.claude/skills/`. The MCP server also sends a short workflow hint.
## Use it from a shell
```bash
node src/cli.js tools
node src/cli.js project_new '{"path":"demo.clipforge.json","aspect":"9:16"}'
node src/cli.js clip_add '{"project":"demo.clipforge.json","path":"a.mp4"}'
node src/cli.js export '{"project":"demo.clipforge.json","out":"out.mp4"}'
```
## Features
| Area | Tools |
|---|---|
| Project | `project_new`, `project_open`, `project_info`, `project_settings`, `undo`, `redo` |
| Media / clips | `media_import`, `clip_add`, `clip_split`, `clip_trim`, `clip_move`, `clip_delete`, `clip_set` (speed, reverse, volume, opacity, fades, position/scale/rotation), `timeline_close_gaps` |
| Titles | `clip_add_text`, `clip_add_color`, `captions_add` |
| Animation | `keyframe_set`, `keyframe_clear`, `clip_animate` — keyframes for x, y, scale, rotation, opacity, volume with easing; presets zoom_in, zoom_out, ken_burns, pop_in, slide_in_*, spin_in, shake, fade_pulse |
| Auto-captions | `captions_auto` (local whisper.cpp speech-to-text, mapped through cuts and speed changes; `highlight_color` paints each word as it is spoken), `captions_import_srt` |
| Effects | `effect_list`, `effect_add`, `effect_remove` — colour, blur, sharpen, vignette, pixelate, grain, chroma key, punch-in zoom, **stabilize** (camera-shake removal), loudness normalise, denoise, EQ, echo, compressor, pitch |
| Speed ramps | `speed_ramp_set` (speed at points along the source), `speed_ramp_preset` (slowmo_dip, hero, speed_up, slow_down), `speed_ramp_clear` — video follows the curve exactly, audio in short pitch-preserving steps; later clips ripple |
| Background removal | `remove_background` — cut out people, pets or objects locally with Apple Vision (modes `subject` / `person`), optional colour or clip behind; also as effect `remove_background` |
| Transitions | `transition_add` — fade (crossfade), slide left/right/up/down |
| Tracks | `track_add`, `track_set` (mute/hide) — higher video tracks draw on top |
| Analysis | `analyze_silence`, `analyze_scenes`, `auto_cut_silence` |
| Live preview | `preview_open`, `preview_close` — browser page with timeline, thumbnails, auto-rendered draft player, change list, undo/redo buttons; also `clipforge preview <project>` |
| Layouts | `clip_layout` — picture-in-picture (4 corners) and split screen (left/right/top/bottom), plus a `crop` clip property |
| Looks & sound presets | `effect_preset` (cinematic, vintage, vivid, warm_glow, cold, bw_contrast, dreamy, voice_clean, radio, hall), effect `lut` for .cube/.3dl film LUTs |
| Title templates | `title_template` — lower_third, chapter card, quote, outro, 3-2-1 countdown |
| Freeze & tracking | `freeze_frame` (hold a frame, ripple the rest), `label_follow` (a text label that follows the subject, tracked by Apple Vision) |
| Checks & interchange | `project_check` (missing files, clips past their media, black gaps, overlaps), `captions_export_srt`, `export_edl` (CMX3600 cut list for Resolve/Premiere) |
| Music & beats | `music_add` (loops/trims/fades, **ducks under speech**), `track_set duck`, `analyze_beats` (BPM + beat grid), `cuts_to_beats` |
| Reframe | `reframe` — new aspect ratio, every clip filled and cropped; `follow` keeps the subject in frame (Apple Vision) |
| Output | `preview_frame`, `contact_sheet`, `export` (.mp4 .mov .webm .gif .mp3 .wav .m4a; presets youtube/shorts/web/draft/gif; draft/standard/high; `hardware` = Mac H.264 encoder, ~3× faster; range; scale) |
Times are seconds. Titles and solid colours go to an automatic `Titles` track.
## Stabilisation
`effect_add` with `type: "stabilize"` analyses the media once (block matching on a blurred 384 px grayscale
copy, cached in `<project>.work/motion2_<media>.json`), smooths the camera path (`smooth` = seconds
averaged) and shifts every frame inside an automatic zoom crop. It corrects translation shake only; the
result reports how shaky the footage was. Analysis takes about 2 s per second of video.
Measured: on synthetic shaky footage the residual shake dropped from 2.3 % to 0.5 % of the frame width and a synthetic 1.1° tilt shake to 0.04°; on
a real handheld 36 s pan (1080p, fast pan over repetitive text) the shake (high-pass, σ = 5 frames) fell by
60–75 % in every 4-second window. Lessons that shaped the estimator: repeated texture (letters, fences)
makes plain block matching jump by one period in ~15 % of frames, which injects jitter instead of removing
it; blurring the analysis frames (σ = 5 px at 384 px width) cured that. ffmpeg's `deshake` (only ~25 %) and
`vidstab` (not in the Homebrew build) were not an option.
## Background removal
`remove_background` uses Apple's Vision framework through a small Swift helper
(`native/matte.swift`, compiled on first use into `bin/matte`; needs macOS 14+ and the Xcode command
line tools). Nothing is downloaded or uploaded. `subject` mode finds the salient foreground (people,
pets, objects, but it can include props such as a hay bale); `person` mode is people-only and uses
temporal information between frames. The matte is cached in `<project>.work/` and merged into the
clip's alpha channel before any other effect, with `feather`, `choke` and `smooth` (temporal
averaging) to tune the edge. The result reports how much of the frame was covered, so an empty
detection is noticed. Fast motion can leave a faint halo; the hair/fur edge is only as fine as
Vision's mask.
## Speed and big projects
- Draft renders (the live preview) read small **proxies** of footage larger than 1280 px (made once in
`<project>.work/proxy/`); exports always use the originals. 1080p previews render ~2.4× faster, 4K much more.
- `export` with `hardware: true` uses the Mac's H.264 encoder (3.3× faster on the test video).
- Timelines with more than 60 inputs render with a single-threaded filter graph, which avoids ffmpeg's
"Resource temporarily unavailable" failures: 100 clips with titles export fine, 150 take ~100 s.
- MCP clients that send a progress token get progress notifications during exports.
## Live preview
Ask Claude to call `preview_open` (or run `node src/cli.js preview <project>`) and open the URL it
returns (default http://127.0.0.1:4545/, local only). The page shows the timeline with thumbnails,
shows waveforms for audio, re-renders a low-resolution draft video a moment after every change to the project file, highlights
changed clips and lists what changed.
You can also edit by hand in the timeline: **drag** a clip to move it (it snaps to other clip edges and the
playhead, and can be dropped on another track of the same kind), **drag its edges** to trim, **S** splits
the selected clip (or every clip) at the playhead, **Delete** removes the selected clip (**Shift+Delete**
closes the gap), **⌘/Ctrl+Z** undoes, **Space** plays, **←/→** step a frame. Hand edits go through the same
tools as Claude's, so they land in the same undo history. The server listens on 127.0.0.1 only, checks the
Host/Origin headers and requires a custom header on every POST, so a website you visit cannot edit your
project; the page may only call timeline-editing tools (split, move, trim, delete, clip_set).
Media that lives only in the cloud (e.g. OneDrive "files on demand") cannot be read until it is
downloaded — use `media_collect` once the files are local to copy everything next to the project.
## Auto-captions setup
`captions_auto` needs `whisper-cli` (`brew install whisper-cpp`) and a model in `models/`
(`ggml-small.bin` from https://huggingface.co/ggerganov/whisper.cpp). The model is not part of the
source; set `CLIPFORGE_WHISPER_MODEL` to use another file. The whole media file is transcribed once
and cached in `<project>.work/`, because whisper is much less accurate on short cut snippets.
Pass `language` (e.g. `en`, `de`) when you know it — auto-detect can misfire on short intros.
On audio without speech (wind, machines, music) whisper invents text; lines that are endless repeats of
one character or syllable are dropped, and the tool then reports that no speech was found.
## Tests
```bash
npm test # runs all three groups in a temp folder
node test/smoke.mjs <workdir> # builds + renders a project through the tool layer
node test/mcp-client.mjs <workdir> # drives the stdio MCP server (run smoke first)
```
## License
ISC, see [LICENSE](LICENSE).
## Not built yet
Rotation/perspective stabilisation, true soft-edged matting for hair/fur, animation pivots other than the centre of the
layer (text pivots on itself; footage on the frame centre), a GUI timeline, and import/export of Filmora `.wfp` projects (only the media pool and
project metadata were observable; the timeline data was not in the files inspected).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues