---
name: html-animation-to-video
description: Records one self-contained HTML animation into an MP4 by screen-capturing the browser window with FFmpeg Desktop Duplication and NVENC. Use when the user wants to export, capture, record, or convert an HTML animation into a video file, including HTML produced by html-text-to-animation.
---
# HTML Animation to Video
Open one HTML animation in the already-running local browser, freeze it on its first frame, and
record the screen into a single MP4 once Space starts the timeline.
## Rules
Read and follow [dependency-manager](../dependency-manager.md). Run the bundled script through the repository Python interpreter.
- Require one HTML file path. The output directory is optional and defaults to the directory that holds the HTML file.
- Do not start the web service or the browser. Both must already be running; the script only asks the service to open the page and to press Space.
- The service must run with a visible browser window (`BROWSER_HEADLESS=false`). In headless mode `/animation/open` fails with `HEADLESS_BROWSER` and the script stops before recording.
- Windows only: capture uses the Desktop Duplication API (`ddagrab`). Encoding probes `hevc_nvenc`, then `h264_nvenc`, and falls back to CPU `libx264` when no NVENC encoder answers.
- The page must stay paused on its first frame and declare its duration with ``, replacing `15` with the real duration in seconds. The service reads it from the loaded page and returns it, so the recorder never parses the HTML; `--duration` overrides it.
- Do not add play buttons, seek, pause, or frame-stepping hooks: the recorder starts the page with Space and the timeline runs once.
- Run one recording at a time: playback reuses a single browser tab, so a parallel run would navigate the tab away from the animation being recorded.
- The script records the secondary display and moves the browser onto it, so the primary display stays usable. Keep that display clear and leave the machine alone until the script reports completion: the recorder captures screen pixels, so any window that covers the browser, a screen saver, or a display that sleeps ends up in the video.
- The script switches the window to browser fullscreen (F11) so the page owns the whole monitor, and re-raises it above other windows. A window that is fullscreen on the other display is taken out of fullscreen first, because the window manager ignores a move while fullscreen. If the window stays windowed, the script records the client area and warns; a rectangle that falls outside the recorded display stops the run with an error.
- Anything up to a 4K capture works at any Windows display scale: the recorder is DPI aware, so a 150% scale still captures the full monitor.
- An existing `.mp4` is replaced without asking, so mention that when reporting the result.
- Leave the desktop as it was found: the script exits fullscreen and closes the playback tab when it finishes, whether the recording worked or not.
## Run
From the repository root:
```bash
.dependency/python/python .agents/skills/html-animation-to-video/scripts/record.py --html path/to/animation.html
```
| Flag | Meaning |
|------|---------|
| `--html` | Path to the self-contained HTML animation |
| `--output` | Directory for the recorded MP4 (default: the HTML file's directory) |
| `--duration` | Seconds, overriding the duration declared by the page |
| `--fps` | Capture frame rate (default `60`) |
The MP4 is written to `