Metadata-Version: 2.4
Name: visualkit
Version: 3.0.1
Summary: Programmable, local-first video editing engine for developers and AI agents: versioned SQLite timelines, exact rational clocks, Fusion node graphs, motion graphics, local actors, multi-agent claimed regions, and FFmpeg rendering.
Author-email: Suraj Airi <surajairi.ml@gmail.com>
License: MIT
Project-URL: Homepage, https://visualkit.hyekai.com
Project-URL: Documentation, https://visualkit.hyekai.com/docs
Project-URL: Repository, https://github.com/surajairi/visualkit
Project-URL: Issues, https://github.com/surajairi/visualkit/issues
Keywords: video-editing,ai-agents,programmatic-video,motion-graphics,ffmpeg,compositing,node-graph,timeline,keyframes,remotion,skia,sqlite
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Multimedia :: Video :: Non-Linear Editor
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS.rst
Requires-Dist: pydantic>=2.13.5
Requires-Dist: typing-extensions>=4.16.0
Requires-Dist: tomli>=2.0.1; python_version < "3.11"
Provides-Extra: render
Requires-Dist: playwright>=1.40.0; extra == "render"
Provides-Extra: style
Requires-Dist: skia-python>=144.1; extra == "style"
Provides-Extra: dev
Requires-Dist: mypy>=2.4.1; extra == "dev"
Requires-Dist: notebook>=7.6.2; extra == "dev"
Requires-Dist: pyright>=1.1.414; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
Requires-Dist: ruff>=0.12.1; extra == "dev"
Dynamic: license-file

# VisualKit

**A programmable, local-first video editing engine built for developers and AI agents.**

[Website](https://visualkit.hyekai.com) · [Documentation](https://visualkit.hyekai.com/docs) · [CLI Reference](https://visualkit.hyekai.com/docs/cli-reference) · [Agent Skills](https://visualkit.hyekai.com/docs/skills) 

---

VisualKit replaces brittle FFmpeg command strings and GUI-only timelines with a strictly typed Python engine backed by a versioned SQLite project store. Every edit is validated atomically before hitting disk, every timestamp uses exact rational arithmetic (`Fraction`), and multiple AI agents can edit disjoint windows of the same timeline in parallel without merge conflicts.

## Why VisualKit

- **Git-like versioned timeline store**: Projects live in a single SQLite file (`project.visualkit`) with content-addressed revisions, checkpoints, undo/redo, branches, 3-way entity merges, and Git-diffable canonical JSON export/import.
- **Multi-agent claimed regions**: Lock disjoint `[start, end)` time windows on the same branch so parallel agents edit in claim-local `0.0s` coordinates with automatic downstream ripple on release.
- **Exact rational clocks & commit-time integrity**: Typed time domains (`Time`, `TimelineTime`, `ClipTime`, `SourceTime`, `AnimTime`) eliminate float drift; overlaps, out-of-bounds trims, DAG cycles, and dangling references fail atomically before commit.
- **Compositing, motion graphics & local actors**: Combine built-in visual/audio effects, track-wide adjustment clips, DAG-based Fusion node graphs, Skia-styled text/shapes/templates, and 6 local-first media actors (`ffmpeg_lut`, `bg_remove`, `rembg`, `transcribe`, `media_tools`, `local_broll`).
- **Agent-native ergonomics**: Structured `--format json` CLI output, deterministic exit codes (`0–4`), `--dry-run` validation, fast frame/grid visual previews, and ready-to-use Agent Skills (`visualkit-editing`, `visualkit-collab`).

## Installation

Requires **Python 3.10+** and **FFmpeg / FFprobe** on `PATH`.

```bash
# With uv (recommended)
uv add visualkit

# Or with pip
pip install visualkit
```

### Optional Extras

| Extra | Command | What it enables |
| --- | --- | --- |
| `style` | `uv add "visualkit[style]"` | Skia vector rasterization — **required** for `ShapeClip` and shape-based templates (without it, `TextClip` falls back to basic FFmpeg `drawtext`) |
| `render` | `uv add "visualkit[render]"` | Playwright browser automation for HTML coded visual assets |
| Both | `uv add "visualkit[style,render]"` | Full vector styling + HTML coded visuals |

For coded visual compilers (HTML and Remotion), check local dependencies with `visualkit-doctor check`.

## 60-Second Quickstart

### CLI Workflow (`init` → `exec` → `preview` → `render`)

```bash
# 1. Initialize a versioned project store
visualkit init demo.visualkit --title "Launch Teaser" --fps 30 --width 1920 --height 1080 --format json

# 2. Scan media from your project folder (auto-mounted at /proj)
export VISUALKIT_PROJECT_DIR=./media
visualkit asset scan /proj --recursive --format json
```

Write an editing script (`edit.py`) — `visualkit exec` injects `engine` (`VisualkitEngine`) and commits atomically on exit:

```python
from visualkit import Geometry, Shadow

with engine.edit(label="create intro"):
    v_bg = engine.create_track("visual", name="Background")
    v_fg = engine.create_track("visual", name="Titles")

    engine.add_shape(
        Geometry.rect(1920, 1080),
        visual_track_id=v_bg.id,
        start_ts=0.0,
        duration=4.0,
        fill="#0F172A",
    )

    title = engine.add_text(
        "Built with VisualKit",
        visual_track_id=v_fg.id,
        start_ts=0.3,
        duration=3.4,
        font_size=96,
        color="#F8FAFC",
        font_weight=700,
        shadow=Shadow.drop(),
    )
    title.place_at(960, 540)
    title.fade_in(0.4).pop_in(from_scale=0.92, duration=0.4).fade_out(0.4)
```

```bash
# 3. Validate without writing, then commit
visualkit exec edit.py --db demo.visualkit --dry-run --format json
visualkit exec edit.py --db demo.visualkit --format json

# 4. Preview a contact sheet before full export, then render
visualkit preview grid --db demo.visualkit --frames 6 --cols 3 -o preview.jpg --format json
visualkit render out.mp4 --db demo.visualkit --format json
```

### Direct Python API

```python
from visualkit import FfmpegRenderer, RenderOptions, VisualkitEngine

with VisualkitEngine.open("demo.visualkit", fps=30, resolution=(1920, 1080)) as engine:
    with engine.edit(label="add title"):
        v1 = engine.create_track("visual", name="V1")
        clip = engine.add_text("Hello World", visual_track_id=v1.id, start_ts=0.0, duration=3.0, font_size=72)
        clip.fade_in(0.3).fade_out(0.3)

    engine.save(label="initial cut")
    engine.preview_grid("timeline", num_frames=4, out_path="preview.jpg")
    result = FfmpegRenderer().render(engine.store, "out.mp4", options=RenderOptions())
```

## Core Capabilities

### Timeline, Clips, Cropping & Speed Curves
- **Clip types**: `MediaClip`, `AudioClip`, `TextClip`, `ShapeClip`, `CodedVisualClip`, `AdjustmentClipVisual`/`Audio`, `FusionClipVisual`/`Audio`, `CompoundClipVisual`/`Audio`, and `TemplateClipVisual`/`Audio`.
- **Non-linear editing**: `move`, `trim_head`, `trim_tail`, `split(TimelineTime(...))`, `split_all`, `ripple_insert`, `ripple_delete`, `close_gap`, `shift_items`, `engine.snap(t)` for exact frame-grid snapping, and linked A/V preservation.
- **Cropping & color**: Keyframable `Transform.crop` (`crop_to` with `FitMode`, `CropAlignment`, and `source_position`), signed-offset `set_human_props(...)`, and `AudioClip.equalizer`.
- **Speed ramping**: Constant speed (`set_speed(2.0, shrink_to_fit=True)`) and piecewise speed curves (`set_speed_curve([SpeedPoint(at=..., speed=..., interpolation=LINEAR|HOLD)])`) with exact rational integration.

### Two-Layer Keyframes, Vector Styling & Templates
- **Two-layer animation**: `Layer.PRE` (source time, replaces static base and stretches with `TimeMap`) and `Layer.POST` (cut-relative time, combines onto `PRE`/static via `ADD`, `MULTIPLY`, or `REPLACE`).
- **Motion presets**: Chainable `fade_in`, `fade_out`, `slide_in`, `slide_out`, `pop_in`, and `draw_in`, plus `LINEAR`, `HOLD`, `EASE_IN`, `EASE_OUT`, `EASE_IN_OUT`, and custom cubic `BEZIER` curves.
- **Styling & built-in templates**: Full `TextStyle`, `Geometry`, `Paint`, `Stroke`, `Shadow`, managed SIL OFL Noto fonts (downloaded on first use; see the fonts note in the style guide), and 5 parameterized templates (`title_card`, `lower_third`, `subtitle`, `callout`, `progress_ring`).

### Effects, Adjustment Clips & Fusion Node Graphs
- **Per-clip & track-wide effects**: `GaussianBlurEffect`, `DropShadowEffect`, `GlowEffect`, `SharpenEffect`, `PixelateEffect`, `VignetteEffect`, `ChromaKeyEffect`, `MaskEffect`, `CompressorEffect`, `ReverbEffect`, `EchoEffect`, `DistortionEffect`, `PanEffect`, and `AdjustmentClip`.
- **Fusion DAGs**: Build validated acyclic node graphs (`FusionInputNode`, `FusionGeneratorNode`, `FusionEffectNode`, `FusionColorGradeNode`, `FusionMaskNode`, `FusionApplyMaskNode`, `FusionMergeNode`, `FusionPluginNode`, `FusionAudioMixNode`, `FusionOutputNode`) usable as standalone `FusionClip`s or reusable single-input `graph.as_effect()` stacks.

### Compound Clips & Template Repeaters
- Package reusable nested sequences as `CompoundClip`s with typed exposed `VariableSpec`s (`string`, `number`, `integer`, `boolean`, `json`, `asset`).
- Drive staggered lists, bullet overlays, and lower-third sequences with `SequenceHandle.set_repeater(...)` and `engine.add_template_clip(...)`.

### Built-in Local Actors

Local-first media plugins accessible via `visualkit actor <slug> ...`, `visualkit actors run`, and `FusionPluginNode` (pass `--save-asset` to auto-register outputs into `AssetResolver`):

| Actor | Surfaces | Purpose |
| --- | --- | --- |
| `ffmpeg_lut` | CLI, Fusion (native) | 3D `.cube` LUT grading (`teal_orange`, `cinematic_warm`, `noir_bw`, `vintage_fade`, `crisp_daylight`, `kodak_2383_d65`, or custom `.cube`) with RGBA intensity blending |
| `bg_remove` | CLI, Fusion (native) | Fast zero-dependency FFmpeg chroma-key removal with alpha-only `feather` |
| `rembg` | CLI, Fusion | Local AI subject segmentation via ONNX (CPU/CUDA/CoreML, raw FFmpeg pipe streaming) |
| `transcribe` | CLI | Unified local ASR (`faster_whisper`, `whisperx`, `insanely_fast_whisper`) with word-level JSON/SRT/VTT output |
| `media_tools` | CLI | Fast FFmpeg/FFprobe helpers: `probe`, `extract-frames`, `detect-scenes`, and `trim` |
| `local_broll` | CLI | Offline synthetic B-roll MP4 generator for rapid prototyping and tests |

### Director's Cut, Assets & Collaboration
- **Director's Cut**: Non-rendered `EditingPlan`, project stage registry, nested `StoryboardClip`s with per-stage hints, and time- or item-anchored `DirectorMarker`s that ripple with edits.
- **Assets & Coded Visuals**: `AssetResolver` with virtual mounts (`/proj`, `/home`, `/global`, plus custom mounts), proxy variants, FTS5 search, path-free `AssetPin` staleness checks, and cached HTML/Remotion coded visuals.
- **Collaboration & Claimed Regions**: Checkpoints (`checkpoint`, `diff`, `restore`, `revert`), branches & 3-way merge (`branch`, `merge`), bound sessions (`workspace`), and disjoint parallel editing (`workspace new --claim START END --on-straddle split`, `claim release`, `claim abort`).

## Built for AI Agents

VisualKit ships two structured Agent Skills under [skills/](https://github.com/SurajAiri/visualkit/tree/main/skills) designed for progressive disclosure:

- [skills/visualkit-editing/SKILL.md](https://visualkit.hyekai.com/downloads/skills/visualkit-editing.zip) — End-to-end editing playbook plus focused references for effects/Fusion, compound/repeaters, and Director's Cut/coded visuals.
- [skills/visualkit-collab/SKILL.md](https://visualkit.hyekai.com/downloads/skills/visualkit-collab.zip) — Checkpoints, branching, 3-way merges, workspaces, and multi-agent claimed regions.

New to directing an agent? [Getting Started (Human)](https://visualkit.hyekai.com/docs/getting-started-human) walks through importing the skills, pointing the agent at your footage, and reviewing previews before you render.

Every CLI command supports `--format json` with deterministic exit codes (`0=ok`, `1=validation_error`, `2=script_crash`, `3=merge_conflict`, `4=claim_refused`).

## Documentation

Full guides live in [docs/](https://visualkit.hyekai.com/docs):

| Guide | Topic |
| --- | --- |
| [Getting Started](https://visualkit.hyekai.com/docs/getting-started) | Installation, FFmpeg/extras, and your first 5-minute project |
| [Getting Started (Human)](https://visualkit.hyekai.com/docs/getting-started-human) | Directing an AI agent (Claude Code, Codex, Cursor, Gemini CLI): import the skills, give it your assets, review previews, and render |
| [Agent Skills](https://visualkit.hyekai.com/docs/skills) | Download `visualkit-editing` and `visualkit-collab`, and where each agent expects them |
| [Core Concepts](https://visualkit.hyekai.com/docs/core-concepts) | Exact rational clocks, flat entities, transactions, validation |
| [Assets \& Coded Visuals](https://visualkit.hyekai.com/docs/assets) | Virtual mounts (`/proj`), variants, `AssetPin`, HTML & Remotion |
| [Clips \& Timeline Editing](https://visualkit.hyekai.com/docs/clips-and-timeline) | Tracks, cropping, human color scales, speed curves, NLE & ripple ops |
| [Keyframes \& Animation](https://visualkit.hyekai.com/docs/keyframes-and-animation) | `PRE`/`POST` layers, `Combine` semantics, Bezier & motion presets |
| [Style, Text, Shapes \& Templates](https://visualkit.hyekai.com/docs/style-text-shapes-templates) | `TextClip`, `ShapeClip`, `Geometry`, `Paint`, Skia & templates |
| [Effects \& Fusion Graphs](https://visualkit.hyekai.com/docs/effects-and-fusion) | Visual/audio effects, adjustment clips, Fusion DAGs & `as_effect()` |
| [Compound \& Template Clips](https://visualkit.hyekai.com/docs/compound-and-template-clips) | Nested sequences, exposed variables, and repeater templates |
| [Director's Cut](https://visualkit.hyekai.com/docs/director-cut) | Stages, storyboards, markers, and non-rendered review layer |
| [Built-in \& Local Actors](https://visualkit.hyekai.com/docs/actors) | All 6 local-first actors, CLI subcommands, and Fusion integration |
| [Preview \& Rendering](https://visualkit.hyekai.com/docs/preview-and-rendering) | Frame/grid/video/compare previews and FFmpeg rendering |
| [Version Control \& Collaboration](https://visualkit.hyekai.com/docs/version-control-and-collaboration) | Checkpoints, branching, 3-way merge, workspaces, claimed regions |
| [CLI Reference](https://visualkit.hyekai.com/docs/cli-reference) | Full `visualkit` & `visualkit-doctor` CLI reference and exit codes |

## Development

```bash
uv sync --group dev
uv run pytest tests -ra
uv run ruff check src tests
uv run mypy src
uv run pyright src
mkdocs build --strict
```

## License

MIT — see [LICENSE](https://github.com/surajairi/visualkit/blob/main/LICENSE).
