Metadata-Version: 2.4
Name: video-digest-cli
Version: 0.1.0
Summary: Turn a screen recording into a digest an LLM can read in one pass: change-detected key frames, transient states, inferred clicks, OCR and a Markdown timeline. Runs locally.
Author: Scott Havird
License-Expression: MIT
Project-URL: Homepage, https://github.com/scotthavird/video-digest
Project-URL: Issues, https://github.com/scotthavird/video-digest/issues
Project-URL: Hosted API, https://contentindexer.com
Keywords: video,screen-recording,llm,mcp,agents,ocr,claude
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: opencv-python-headless>=4.8
Requires-Dist: numpy>=1.24
Provides-Extra: mcp
Requires-Dist: mcp>=1.2; extra == "mcp"
Provides-Extra: vision
Requires-Dist: pyobjc-framework-Vision>=10; sys_platform == "darwin" and extra == "vision"
Provides-Extra: whisper
Requires-Dist: faster-whisper>=1.0; extra == "whisper"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# video-digest

[![CI](https://github.com/scotthavird/video-digest/actions/workflows/ci.yml/badge.svg)](https://github.com/scotthavird/video-digest/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/video-digest-cli)](https://pypi.org/project/video-digest-cli/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/scotthavird/video-digest/blob/main/LICENSE)

Agents can't watch video. `video-digest` turns a screen recording, bug repro, demo or talk into
something an LLM can read in one pass: a Markdown timeline of what changed on screen, the few key
frames that matter, the text on them, and what the pointer did, all on your machine.

![video-digest on a 6-second checkout bug: the 400 ms "Invalid code" toast after clicking Apply](https://raw.githubusercontent.com/scotthavird/video-digest/main/docs/demo.gif)

From a real bug repro, a React app's error overlay:

```
- [00:00.0] **frame 1** · settled 1.0s → frames/001_00m00.0s.jpg
- [00:01.0] **frame 2** · settled 1.2s · after click "Underli..." at (234,496) · disappeared middle-left
- [00:02.2] back to frame 1 (same screen) · transient 900ms · after click "Underline" at (257,425)
- [00:03.3] **frame 3** · settled 2.3s · after click "Wor B..." at (240,552) · appeared middle-left:
  "Uncaught runtime errors: ERROR durationInFrames must be positive, but…" · ⚠ error
```

## Quick start

```bash
pip install 'video-digest-cli[mcp]'              # or: uvx --from video-digest-cli video-digest bug.mov
video-digest bug.mov --print                 # Markdown timeline to stdout
claude mcp add video-digest -- uvx --from 'video-digest-cli[mcp]' video-digest-mcp   # Claude Code
```

## What it does

| | |
|---|---|
| **Change detection** | Samples the video (10 fps for clips under 2 min, 4 fps up to 10 min, 1 fps beyond), diffs grayscale frames, and keeps a frame only when the screen really changes. Pointer-sized blobs don't count. |
| **Settled / transient / motion** | A state held ≥ 1 s is *settled*. Shorter is *transient* (toasts, spinners, error flashes: often the bug). Animation, scrolling and embedded video are *motion*. A run of short, never-repeating states becomes one motion segment. |
| **Repeats** | A screen that matches an earlier one becomes "back to frame N" and costs no image. A brief change that snaps back is folded in as "flickered N×". |
| **Diff regions** | Bounding boxes of what changed, labelled *appeared / disappeared / changed* plus a position (top-right, …), with a crop and the OCR text inside the box ("appeared bottom-right: 'Invalid code'"). |
| **Pointer + clicks** | Tracks the system pointer (a small dark-and-light blob that moves). If the pointer came to rest just before a change, it's an inferred *click*, labelled with the text under it. If it was still moving, it's a *hover*. |
| **OCR** | macOS Vision when `pyobjc-framework-Vision` is installed (fast, accurate), else the Tesseract CLI, else none. |
| **Transcript** | `--transcript talk.vtt` (or .srt) aligns speech per segment. `--whisper base` runs local faster-whisper if installed. |
| **Budget** | `--budget N` caps the key frame images. Frames are ranked by first/last position, transient status, change size and duration, then shown in order. |
| **Busy areas** | In videos 30 s or longer, areas that change all the time (webcam tile, playing video) are masked out and named in the header. In videos over 5 min, a new state also needs ≥ 1 % of the frame to change, which keeps slides and drops speaker badges. |

Output in `-o out/`:
- `digest.md`: the timeline plus a "Key frames" section with images and on-screen text.
- `frames/NNN_MMmSS.Ss.jpg`: key frames (1280 px wide), with `_rN.png` crops of the changed regions.
- `digest.json`: everything, machine-readable, including segments, regions, actions, the cursor track, settings and timings.

## Install

The PyPI package is `video-digest-cli`; it installs the `video-digest` and `video-digest-mcp` commands. Needs Python ≥ 3.10. ffmpeg is recommended (faster decoding and seeking); without it, OpenCV decodes.

```bash
pip install 'video-digest-cli[mcp]'                     # + '[vision]' on macOS for Apple's OCR
brew install ffmpeg tesseract                        # optional, but recommended
```

## CLI

```bash
video-digest bug.mov                       # -> bug.digest/digest.md
video-digest bug.mov -o out/ --budget 12 --print
video-digest talk.mp4 --transcript talk.vtt --budget 30
video-digest flow.mov --fps 15 --settle 0.5 --sensitivity 2   # catch smaller / faster changes
```

## MCP server (Claude Code, Cursor, …)

```bash
claude mcp add video-digest -- video-digest-mcp            # if installed with pip
claude mcp add video-digest -- uvx --from 'video-digest-cli[mcp]' video-digest-mcp   # nothing to install
```

Other MCP clients: run `video-digest-mcp` as a stdio server.

Tools:
- `watch_video(path, budget=12, transcript=None, include_images=True)` returns the timeline and the key frame images in one tool result. Results are cached in `~/.cache/video-digest` by file and budget.
- `frame_at(path, t)` returns one full frame at a timestamp, for a closer look at a moment from the timeline.

Then ask: *"watch ~/Desktop/bug.mov and tell me what broke"*.

## Limits

- Clicks are inferred: the mouse button isn't visible in most recordings, and a pointer that is hidden or very small isn't tracked.
- Tuned for screen recordings. Camera footage changes every frame and mostly comes out as motion; use scene detection for that.
- Long videos load all samples into memory (capped at ~600 MB by lowering the analysis width).
- Library-wide search, speaker-labelled transcripts, long-video processing and sharing are what the hosted [ContentIndexer](https://contentindexer.com) API does.

## Development

```bash
git clone https://github.com/scotthavird/video-digest && cd video-digest
uv venv && uv pip install -e '.[dev,mcp,vision]'
.venv/bin/python -m pytest tests -q
```

The tests build a synthetic screen recording (page → pointer glides and rests on a button → 400 ms
toast → back → new page) and check states, transient detection, click inference, budget, CLI and MCP.
`python docs/make_demo.py` rebuilds the demo GIF from that same clip (needs [agg](https://github.com/asciinema/agg)).
How it was tuned on real recordings: [SPIKE_NOTES.md](https://github.com/scotthavird/video-digest/blob/main/SPIKE_NOTES.md).

Releases: bump `version` in `pyproject.toml` and `video_digest/__init__.py`, then push a `vX.Y.Z` tag.
The release workflow builds and publishes to PyPI (trusted publishing) and creates the GitHub release.

MIT licensed.
