imovie-cli

module
v0.0.0-...-6dc8561 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0

README

imovie-cli

Go CLI and MCP tools for reworking an existing video cut with your own footage. Inspect the agency edit, find shots, split and replace sections, preserve its soundtrack, add transitions and location titles, and render a revision.

Current status: working local media/editing tools and a stdio MCP server. The edit timeline is a JSON document owned by this tool. Rendering produces an MP4 you can import into iMovie; it does not modify an existing native iMovie timeline or recover editable layers from a finished movie. Native macOS tools cover status, launch, and an experimental import-dialog helper. A separate native timeline prototype now supports checked shot splits and verifies detached audio; it is not yet part of the Go CLI/MCP API.

Install

Requires Go 1.25+ and FFmpeg/ffprobe on your PATH. FFmpeg must include libx264, AAC, xfade, and overlay. Titles are drawn in Go, so FFmpeg's optional drawtext filter is not required. Media operations work on macOS and Linux; native iMovie operations require macOS, iMovie, and macOS Automation/Accessibility access.

brew install go ffmpeg
go install github.com/hev/imovie-cli/cmd/imovie-cli@latest
imovie-cli doctor

Or clone and run make build; the binary is bin/imovie-cli.

Start with an existing cut

imovie-cli probe /path/to/agency.mp4
imovie-cli scenes --source /path/to/agency.mp4 --out .local/scenes.json
imovie-cli storyboard --source /path/to/agency.mp4 --out .local/board.jpg
imovie-cli project new --source /path/to/agency.mp4 --out .local/v1.json --keep-audio

Shot boundaries are suggestions. Detection examines every frame at reduced resolution; dissolves, camera motion, and flashes need review. storyboard samples the entire movie and labels each tile with its source timestamp. frame --source FILE --at 18.5 --out .local/frame.jpg inspects a precise moment.

The initial project references the entire source without copying it. --keep-audio keeps the original continuous soundtrack under picture edits. Omit it to use each clip's own audio, crossfading audio alongside transitions. Footage without audio receives silence.

Revise through CLI or chat

Every change writes a new JSON revision. Earlier revisions remain usable; undo means choosing the earlier file. Originals and existing outputs are never overwritten, including when two tool calls race to publish the same output.

imovie-cli project edit --project .local/v1.json --change examples/split.json --out .local/v2.json
imovie-cli project show .local/v2.json
imovie-cli project edit --project .local/v2.json --change examples/location-title.json --out .local/v3.json
imovie-cli render --project .local/v3.json --out .local/preview.mp4 --preview

An edit change is one of:

Operation Fields Meaning
split clip_id, at Split at an offset in seconds within this clip, not a global/source timestamp.
replace clip_id, clip Replace its source/range; retain its ID and outgoing transition.
insert clip_id, clip Insert a uniquely named clip after this clip.
remove clip_id Remove this clip.
title title Add text with output-timeline start/end and position.
transition clip_id, transition Set the transition into the next clip; null removes it.

To replace a range inside a long clip, split at both ends first. read_project or project show returns the resulting stable IDs. Complete JSON revisions can also be authored directly or saved with MCP's save_project.

See examples/edit.json for a full edit with replacement footage, a dissolve, a location title, and continuous agency audio. Filenames in that example are placeholders. Paths inside a hand-authored project resolve relative to the JSON file; new paths in edit commands resolve from the CLI/MCP working directory. Saved revisions use absolute paths.

Durations round to the nearest output frame. A transition overlaps the two clips and shortens the total edit; a 0.5-second dissolve between two 4-second clips produces 7.5 seconds. Titles and continuous audio remain anchored to the output clock when clips are inserted, removed, or shortened. Review their timing after structural edits. Audio from a finished movie is already mixed: preserving it does not separate dialogue, music, or effects.

Supported transitions: dissolve, fadeblack, wipeleft, wiperight. Title positions: bottom-left (default), bottom-right, top-left, center. Optional font_size is in output pixels. Text is rendered literally, including quotes and punctuation. Long titles need line breaks or a smaller font size.

The renderer supports SDR, 1–64 clips, up to 64 titles, even dimensions up to 3840×3840, and 1–120 fps. Mixed aspect ratios are fitted with black padding. HDR input is rejected pending explicit tone mapping. Final renders use one H.264/AAC encode; previews cap the longest dimension at 1280 pixels. Heavy renders/scene scans are synchronous and cancellable; use the CLI when a chat client's tool timeout is too short.

Search footage

imovie-cli index --root /path/to/footage --match holiday --out .local/catalog.json
imovie-cli search --catalog .local/catalog.json --query 'harbor sunset'

Local search matches filenames and optional descriptions, tags, locations, and transcripts added to catalogue entries. This initial indexer records metadata; it does not automatically caption, transcribe, or embed videos.

For visual/semantic search, the Layer adapter queries an already populated namespace through its configured embedding source field:

export LAYER_GATEWAY_URL=https://your-gateway.example
# Supply LAYER_GATEWAY_API_KEY through your environment/secret manager.
imovie-cli search --namespace footage --field image_url --query 'harbor at dusk'

The request uses rank_by: [field, "ANN", ["Embed", query]]. A CLIP image field can retrieve frames from text; a text field can retrieve transcript/description segments. Store source, start, end, and a thumbnail reference in each row so returned hits map back to playable source ranges. Actual model provisioning, frame uploads, transcription, and indexing pipelines are not implemented here yet. No media leaves the machine unless you separately configure and run an upload/indexing workflow. Semantic queries send your query text to the gateway. See Layer's embedding contract.

MCP

Run imovie-cli mcp from any client that supports local stdio MCP servers:

{
  "mcpServers": {
    "imovie": {
      "command": "/absolute/path/to/imovie-cli",
      "args": ["mcp"]
    }
  }
}

The 16 tools share the CLI's implementation: doctor, probe_media, detect_scenes, extract_clip, extract_frame, storyboard, create_project, read_project, save_project, edit_project, render_project, index_footage, search_footage, imovie_status, imovie_open, imovie_import_dialog. MCP stdout contains protocol messages only. Tool errors are reported as errors, and cancellation stops subprocesses. This is a local server with access to the files of the account running it; it has no HTTP listener or remote shell tool.

Example request after connecting:

Inspect this cut and show me its storyboard. Split the shot I select, search my catalogue for replacement footage, and save a new revision with the agency audio preserved. Add a location title and render a preview.

Native iMovie bridge

imovie-cli imovie status
imovie-cli imovie open
imovie-cli imovie import-dialog /path/to/preview.mp4

The experimental import helper uses the English iMovie UI and requires an interactive macOS session. It opens the import window and navigates toward the file; confirm the selection, destination event, and import in iMovie. A successful response means the dialog is open, not that media was imported or added to a timeline. This helper is not part of unattended CI validation.

Native timeline split/replace/title operations are not exposed until they can read and verify actual iMovie state. The implementation never edits iMovie's private library databases or assumes undocumented AppleScript project objects.

The standalone experimental Swift bridge preserves the verified native splitting workflow, resume checks, and audio-detach verification. Its limited frame-rate/UI assumptions are explicit; start with a duplicate project. make check-native builds it and runs synthetic safety checks without touching iMovie.

Development

make check
make build

Tests generate synthetic video, verify transitions and portrait/landscape normalization, scene boundaries, excerpt durations, continuous/clip audio, revision preservation, output collision handling, the Layer query contract, and an MCP client/server tool exchange. FFmpeg integration tests skip when dependencies are missing; CI installs them on macOS and Linux.

Source code is Apache-2.0. Keep footage, local projects, credentials, and generated previews in .local/ or outside this checkout; they are not part of the public repository.

Directories

Path Synopsis
cmd
imovie-cli command
internal
catalog
Package catalog keeps a local, editable catalogue of footage.
Package catalog keeps a local, editable catalogue of footage.
edit
Package edit stores source-referenced edits as immutable JSON revisions.
Package edit stores source-referenced edits as immutable JSON revisions.
imovie
Package imovie exposes only verified, bounded macOS UI operations.
Package imovie exposes only verified, bounded macOS UI operations.
layer
Package layer queries an operator-configured Layer namespace.
Package layer queries an operator-configured Layer namespace.
media
Package media implements local, non-destructive media operations.
Package media implements local, non-destructive media operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL