Metadata-Version: 2.5
Name: citefilm
Version: 0.1.0
Summary: Sourced explainer videos from a YAML spec: local narration, word-synced captions, maps, fact cards and 3D scenes.
Project-URL: Homepage, https://github.com/Weekendwright/citefilm
Project-URL: Documentation, https://github.com/Weekendwright/citefilm/tree/main/docs
Project-URL: Issues, https://github.com/Weekendwright/citefilm/issues
Project-URL: Changelog, https://github.com/Weekendwright/citefilm/blob/main/CHANGELOG.md
Author: Masum Jia
Author-email: Weekendwright <helloweekendwright@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: captions,claude-code,explainer,fact-check,text-to-speech,video
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Video
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: pydantic<3,>=2.7
Requires-Dist: pyyaml>=6.0
Provides-Extra: kokoro
Requires-Dist: kokoro<0.10,>=0.9.4; (python_version < '3.13') and extra == 'kokoro'
Requires-Dist: soundfile<1,>=0.12; extra == 'kokoro'
Provides-Extra: mlx
Requires-Dist: mlx-audio<0.7,>=0.6; (sys_platform == 'darwin' and platform_machine == 'arm64' and python_version >= '3.11') and extra == 'mlx'
Requires-Dist: mlx-whisper<0.5,>=0.4; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'mlx'
Provides-Extra: whisper
Requires-Dist: faster-whisper<2,>=1.1; extra == 'whisper'
Description-Content-Type: text/markdown

# citefilm

**Explainer videos where every number on screen is quoted from a source.**

citefilm turns one YAML file (scenes, narration, sources, and the exact quote behind each fact) into a narrated MP4,
rendered on your own computer: a local voice, captions synced word by word, maps, fact cards and 3D scenes. If a
number on screen is not in a quote that the scene cites, it will not render. Use it from the command line, or let
Claude Code research, write and render a film with the bundled plugin.

[![CI](https://github.com/Weekendwright/citefilm/actions/workflows/ci.yml/badge.svg)](https://github.com/Weekendwright/citefilm/actions/workflows/ci.yml)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/Weekendwright/citefilm/blob/main/LICENSE)
![Python 3.11-3.13](https://img.shields.io/badge/python-3.11%E2%80%933.13-blue.svg)

<p align="center">
  <img src="https://raw.githubusercontent.com/Weekendwright/citefilm/main/docs/media/hero.webp" width="100%" alt="23 seconds of the Point Nemo example film: a map of the South Pacific draws routes from Point Nemo to the three nearest islands under the title About 2,688 km to the nearest land, then a 3D globe shows the space station passing overhead, about 400 km up, with word-synced captions.">
</p>
<p align="center"><sub>23 seconds of <a href="https://github.com/Weekendwright/citefilm/blob/main/examples/point-nemo">Point Nemo</a>, muted here (the film is narrated).
Rendered from <a href="https://github.com/Weekendwright/citefilm/blob/main/examples/point-nemo/spec.yaml">one YAML file</a> with 9 facts quoted from NOAA and NASA.</sub></p>

## Three example films

Each one is a single spec in [`examples/`](https://github.com/Weekendwright/citefilm/blob/main/examples/), rendered by citefilm with nothing edited by hand.

<table>
  <tr>
    <td width="33%" valign="top">
      <a href="https://www.youtube.com/watch?v=YoceWjDtNps"><img src="https://raw.githubusercontent.com/Weekendwright/citefilm/main/docs/media/mars-climate-orbiter.jpg" alt="The Mars Climate Orbiter film: a 3D Mars with the planned and actual approach paths, 226 km planned, 80 km limit, about 170 km lower"></a><br>
      <b>The Mars Climate Orbiter</b> · 89 s · <a href="https://www.youtube.com/watch?v=YoceWjDtNps">watch</a> · <a href="https://github.com/Weekendwright/citefilm/blob/main/examples/mars-climate-orbiter">spec</a><br>
      One file in pound-seconds, not newton-seconds, and a spacecraft lost at Mars (NASA's investigation board).
    </td>
    <td width="33%" valign="top">
      <a href="https://www.youtube.com/watch?v=yir2INwFNOA"><img src="https://raw.githubusercontent.com/Weekendwright/citefilm/main/docs/media/gimli-glider.jpg" alt="The Gimli Glider film: a map of Canada with Flight 143's route from Montreal by way of Ottawa toward Edmonton"></a><br>
      <b>The Gimli Glider</b> · 86 s · <a href="https://www.youtube.com/watch?v=yir2INwFNOA">watch</a> · <a href="https://github.com/Weekendwright/citefilm/blob/main/examples/gimli-glider">spec</a><br>
      A 767 fuelled in pounds instead of kilograms loses both engines at 35,000 feet (Canada's Board of Inquiry).
    </td>
    <td width="33%" valign="top">
      <a href="https://www.youtube.com/watch?v=qsmwKG9SxjQ"><img src="https://raw.githubusercontent.com/Weekendwright/citefilm/main/docs/media/point-nemo.jpg" alt="The Point Nemo film: a 3D globe with the space station's orbit passing over Point Nemo, nearest land 2,688 km, space station 400 km up"></a><br>
      <b>Point Nemo</b> · 69 s · <a href="https://www.youtube.com/watch?v=qsmwKG9SxjQ">watch</a> · <a href="https://github.com/Weekendwright/citefilm/blob/main/examples/point-nemo">spec</a><br>
      The spot in the ocean farthest from land, and why spacecraft are brought down near it (NOAA, NASA).
    </td>
  </tr>
</table>

## Install in 3 commands

Needs [uv](https://docs.astral.sh/uv/), Node.js 22+, FFmpeg and `make`, on an Apple Silicon Mac or Linux
([requirements](#requirements-and-speed)).

```bash
git clone https://github.com/Weekendwright/citefilm && cd citefilm
make setup                                           # Python env with a local voice, render runtime, headless Chrome
uv run citefilm build examples/point-nemo/spec.yaml  # → out/point-nemo/point-nemo.mp4
```

`make setup` installs the Python environment with a voice backend, runs `citefilm runtime install` (the pinned
HyperFrames and three.js, plus a headless Chrome) and ends with `citefilm doctor`, which names anything still missing
and the command that installs it. The first build downloads the voice model (a few hundred MB). On an Apple Silicon
laptop the 69-second Point Nemo film then renders in about 40 seconds. The package is not on PyPI yet;
until it is, install from a clone as above.

## Make your first film

**With Claude Code.** Put the clone's `citefilm` on your PATH (it keeps using the locked environment), then add the
plugin:

```bash
ln -s "$PWD/.venv/bin/citefilm" ~/.local/bin/citefilm   # any folder on your PATH
```

```text
/plugin marketplace add Weekendwright/citefilm
/plugin install citefilm@citefilm
```

Then ask, in plain words:

```text
Make a 60-second explainer about the first transatlantic telegraph cable (1858), from primary sources.
```

The `make-explainer` skill gathers primary sources, builds a fact table with exact quotes, writes the narration,
plans the scenes, runs the fact check and renders the film. The other skills are `fact-check`, `add-scene` and
`render`. The CLI itself needs no account or API key; the plugin uses your Claude Code session.

**By hand.** Copy an example, edit the YAML (the [JSON Schema](https://github.com/Weekendwright/citefilm/blob/main/schema/spec.schema.json) gives your editor
autocomplete), then check and render it:

```bash
uv run citefilm validate my-film/spec.yaml   # schema + fact check; prints the estimated length
uv run citefilm build my-film/spec.yaml      # → out/<slug>/ with the mp4, captions.srt, chapters.txt, sources.md
```

## What it can't do (yet)

- **English only.** Narration uses Kokoro's American and British English voices.
- **Apple Silicon or Linux for narration.** Windows through WSL may work but is untested; an Intel Mac can validate
  specs but has no supported voice backend.
- **A fixed scene vocabulary:** fact cards, a world map and simple 3D shapes. No photos, footage or illustrations,
  and the 3D scenes are schematic, not realistic.
- **A coarse map.** Natural Earth 1:110m: no small islands (they appear as markers), no lakes, rivers or streets.
- **A mechanical fact check.** It checks numbers written with digits against the quotes your spec cites. It never
  opens the sources: whether a quote really appears in its source, spelled-out numbers and wording are for the
  `fact-check` skill and for you.
- **Layouts tuned for 16:9.** Other frame sizes render, but the layouts are not tuned for them yet.
- **No music or sound effects bundled.** You can add your own music file (see [docs/spec.md](https://github.com/Weekendwright/citefilm/blob/main/docs/spec.md)).

## How it works

```mermaid
flowchart LR
    spec["spec.yaml<br/>scenes · narration<br/>sources · facts"] --> check{"validate<br/>schema + fact check"}
    check --> voice["narrator<br/>Kokoro, local"]
    voice --> clocks["word clocks<br/>voice model + optional recogniser"]
    clocks --> plan["timeline + captions<br/>(pure functions)"]
    plan --> scenes["scene renderer<br/>HyperFrames, parallel, cached"]
    scenes --> film["FFmpeg<br/>join · loudness · chapters"]
    film --> out["out/&lt;slug&gt;/<br/>mp4 · srt · chapters · sources · contact sheet"]
```

A film is one YAML file. Each scene has a narration line and a visual. The voice speaks every line locally, the
word times decide when each caption word and each on-screen reveal appears, and every scene is rendered as its own
short video by a headless browser, then joined into one MP4.

## What you get

- **A film from one file.** Scenes, narration, sources and facts live in `spec.yaml`. The same spec renders the same
  film every time.
- **Local narration.** Kokoro (Apache-2.0) runs on your machine: through MLX on Apple Silicon, through PyTorch on the
  CPU everywhere else. No API key, no upload.
- **Captions that never run ahead of the voice.** Word times come from the voice model and, when installed, a speech
  recogniser listening to the finished audio. A word appears when the later of the two says it was spoken.
- **Scene types:** fact cards (title, number, quote, list, compare, fact), an animated world map (camera moves,
  countries, markers, routes) and schematic 3D scenes (planets, spacecraft, aircraft, paths, rings, labels, readouts).
- **Sourced by design.** Every number on screen must appear in the exact quote of a fact the scene cites:
  `citefilm validate` reports it and `citefilm build` refuses to render it. Every film ships with `sources.md`,
  `chapters.txt` and `captions.srt`.
- **Fast re-renders.** Scenes render in parallel and are cached: change one scene and only that scene renders again.
- **Editor support.** A JSON Schema ([`schema/spec.schema.json`](https://github.com/Weekendwright/citefilm/blob/main/schema/spec.schema.json)) gives autocomplete and
  inline errors in any editor with a YAML language server.
- **A Claude Code plugin** with skills for the whole job (topic → research → script → scenes → fact check → render)
  and four helper agents whose speed you choose.

## Speed modes

One setting trades speed and cost against quality, for the helper agents and for the render:

- **fast**: quicker, cheaper helper models; a half-size draft render; voice-model word times only.
- **balanced** (default): your session's model for research and writing, a quicker one for mechanical steps; full
  size; both word clocks when a recogniser is installed.
- **best**: the strongest models for research and writing; full size; both word clocks required.

```bash
citefilm speed fast        # set it for this folder; `citefilm speed` shows the current mode
```

## The spec at a glance

```yaml
# yaml-language-server: $schema=../../schema/spec.schema.json
title: "The Unit Mix-Up That Lost a Mars Orbiter"
voice: {name: am_michael, speed: 1.05}
sources:
  - {id: mib, title: "Mars Climate Orbiter Mishap Investigation Board: Phase I Report", url: "https://llis.nasa.gov/..."}
facts:
  - id: factor
    claim: The navigation software underestimated the thrusters' effect by a factor of 4.45.
    source: mib
    quote: "underestimated the effect on the spacecraft trajectory by a factor of 4.45"
scenes:
  - id: factor
    cite: [factor]
    say: So the software underestimated the thrusters' push by a factor of {4.45.|four point four five.}
    visual: {type: card, style: number, value: 4.45, prefix: "×", label: underestimated, count_at: "@4.45"}
```

`{written|spoken}` shows one thing in the captions and lets the voice say another. `"@4.45"` starts the count when
that word is spoken. Full reference: [docs/spec.md](https://github.com/Weekendwright/citefilm/blob/main/docs/spec.md) and [docs/scenes.md](https://github.com/Weekendwright/citefilm/blob/main/docs/scenes.md).

## Command line

| Command | What it does |
|---|---|
| `citefilm build SPEC` | render a film into `out/<slug>/` (`--only ids` for single scenes, `--speed`, `--workers N`) |
| `citefilm validate SPEC` | check the spec against the schema, then run the fact check |
| `citefilm doctor` | check every dependency and print how to install what is missing |
| `citefilm speed [MODE]` | show or set the speed mode for this folder |
| `citefilm agents` | the helper-agent model per role under the speed mode |
| `citefilm runtime install` | install the pinned render runtime (HyperFrames, three.js, headless Chrome) |
| `citefilm schema` | print the spec's JSON Schema |

Every command takes `--json` for machine-readable output, `-v` and `-q`. Exit codes: 0 success, 1 problems found,
2 invalid input, 3 a tool is missing or failed. Details: [docs/cli.md](https://github.com/Weekendwright/citefilm/blob/main/docs/cli.md).

## Requirements and speed

| | |
|---|---|
| OS | macOS 14 or later on Apple Silicon, or Linux (x86-64 or ARM64). Windows through WSL may work but is not tested. Intel Macs can validate specs, but no supported voice backend runs there. |
| Python | 3.11-3.13 for the tool (uv installs it). The voice needs 3.11-3.13 on Apple Silicon (MLX) or 3.11-3.12 on Linux (Kokoro on PyTorch); `make setup` uses 3.12. With another Python, point the `voice_python` setting at an environment that has a voice backend. |
| Other | Node.js 22+, FFmpeg; HyperFrames downloads its own headless Chrome |
| Memory | about 0.5-1.5 GB per parallel render worker (default: a quarter of your CPU cores, at most 4) |
| Disk | a few hundred MB for the voice model; 0.5-1.6 GB more for the optional recogniser |

Cold renders (empty cache, voice and word clocks included) of the three examples at 1920x1080, 30 fps, with 4 render
workers on an Apple Silicon laptop:

| Film | Length | Scenes | Render time |
|---|---|---|---|
| [Mars Climate Orbiter](https://github.com/Weekendwright/citefilm/blob/main/examples/mars-climate-orbiter) | 89 s | 10 (2 in 3D) | 56 s |
| [Gimli Glider](https://github.com/Weekendwright/citefilm/blob/main/examples/gimli-glider) | 86 s | 10 (1 in 3D) | 48 s |
| [Point Nemo](https://github.com/Weekendwright/citefilm/blob/main/examples/point-nemo) | 69 s | 7 (2 in 3D) | 37 s |

On a CPU-only Linux machine expect several minutes. 3D scenes are the slowest. A re-render after a change only
renders the scenes that changed.

## FAQ

**Does it need an API key or an internet connection?** The CLI does not. After the first downloads (voice model,
headless Chrome) it renders offline. The Claude Code plugin uses your Claude Code session for research and writing.

**Can I use the films commercially?** The code is Apache-2.0 and Kokoro's weights are Apache-2.0. The facts and quotes
come from your sources: check their terms. See [THIRD_PARTY.md](https://github.com/Weekendwright/citefilm/blob/main/THIRD_PARTY.md) for every dependency's licence.

**Can I add a scene type?** Yes: [AGENTS.md](https://github.com/Weekendwright/citefilm/blob/main/AGENTS.md#add-a-scene-type) walks through it (a model, a template, a test).

**Why does a scene render again after I only changed its narration?** The scene's timing changed, so its picture
changed. Scenes whose narration and visual did not change come from the cache.

## Docs

- [Spec format](https://github.com/Weekendwright/citefilm/blob/main/docs/spec.md) · [Scene types](https://github.com/Weekendwright/citefilm/blob/main/docs/scenes.md) · [Finding and quoting sources](https://github.com/Weekendwright/citefilm/blob/main/docs/sources.md) ·
  [Command line](https://github.com/Weekendwright/citefilm/blob/main/docs/cli.md) · [Speed modes and settings](https://github.com/Weekendwright/citefilm/blob/main/docs/settings.md)
- [Contributing](https://github.com/Weekendwright/citefilm/blob/main/CONTRIBUTING.md) · [Security](https://github.com/Weekendwright/citefilm/blob/main/SECURITY.md) · [Changelog](https://github.com/Weekendwright/citefilm/blob/main/CHANGELOG.md) ·
  [Code of conduct](https://github.com/Weekendwright/citefilm/blob/main/CODE_OF_CONDUCT.md)

## Licence

Apache-2.0 ([LICENSE](https://github.com/Weekendwright/citefilm/blob/main/LICENSE), [NOTICE](https://github.com/Weekendwright/citefilm/blob/main/NOTICE)). Fonts: SIL Open Font License. Map data: Natural Earth (public
domain). Third-party licences: [THIRD_PARTY.md](https://github.com/Weekendwright/citefilm/blob/main/THIRD_PARTY.md). If you use citefilm in research, see
[CITATION.cff](https://github.com/Weekendwright/citefilm/blob/main/CITATION.cff). Built with Claude Code.
