Skip to content
Source
Sign inSign up
fuko/rive-preview-player
Open History to see the last commit

README.md

203 lines11.0 KB

1# rive-video-preview
2​
3> **Unofficial project.** This is an independent, community-made tool. It is not affiliated
4> with, endorsed by, or supported by Rive. "Rive" is a trademark of its respective owner.
5​
6https://github.com/user-attachments/assets/be18bae0-6259-4aae-89fc-0f8c92fcea6c
7​
8A video-style preview player for Rive CLI projects: a scrubbable timeline, synced
9audio, frame stepping and copyable timecodes. It runs in a resizable Chrome app window.
10​
11```bash
12rive-video-preview # preview the project in the current directory
13rive-video-preview path/to/project # …or another project
14rive-video-preview build/scene.riv # …or a prebuilt .riv
15rive-video-preview . --at 12.5 # jump to 12.5s (also 1:02.25, f741)
16rive-video-preview . --stop # stop the player for this project
17```
18​
19## How it works
20​
211. `rive . --once --format=json` builds an unsigned `.riv` (about 0.7s). No account and no upload.
222. `rive inspect . --json` supplies the timeline: artboards, animations, fps and work area,
23 plus every `AudioEvent` keyframe (`KeyFrameCallback`) with its asset and volume.
243. A local server (127.0.0.1, port 4810+) serves the player. The page draws frames with
25 `@rive-app/webgl2-advanced`, using `LinearAnimationInstance.time` and `apply()`, so any
26 frame can be shown exactly.
274. Audio bytes come out of the `.riv` through a custom asset loader. The runtime's own
28 audio stays silent. Each sound plays through Web Audio, scheduled against the playhead,
29 so sounds already under way when you press play start partway through, at the correct offset.
305. Saving any project file (`gen/build.py` writing `scene.rml` counts) triggers a rebuild,
31 and the window reloads in place without moving the playhead. A build error
32 appears over the stage, and the player keeps showing the last good build.
33​
34Running the command a second time for the same project reuses the player that is already
35running. With `--at`, the open window jumps to that time.
36​
37## Player
38​
39| Key | |
40|---|---|
41| Space / K | play / pause |
42| ← / → | step one frame · Shift: one second |
43| Home / End | start / end (of the in–out range if set) |
44| I / O / X | set in point / set out point / clear (playback loops inside the range) |
45| C | copy timecode: `00:12.350 (frame 741)` |
46| Shift+C | copy range: `00:10.000–00:12.500 (frames 600–750)` |
47| G | go to time (or double-click the timecode) |
48| L / M / F | loop / mute / fullscreen |
49| S | screenshot the current frame and open its note |
50| N | show / hide the screenshots & notes panel |
51| ↑ / ↓ | move the selected sound effect up / down a track |
52| A | hide / show the audio tracks |
53​
54To copy the playhead time you can also click the timecode. Each copied timecode is also
55printed in the terminal running the player. Scroll on the timeline to zoom, Shift-scroll
56or a horizontal scroll pans, and a double-click on the ruler resets the zoom.
57​
58## Audio tracks and sound-effect levels
59​
60Below the stage, every sound effect (each `AudioEvent` keyframe) is a clip on an audio track,
61with its waveform drawn at the level it plays at.
62​
63- **+ Track** adds a track, up to 3. Each track has a name, **M** (mute), **S** (solo), a volume
64 slider (0–150%, double-click resets) and a remove button. Removing a track moves its sound
65 effects to the track above it.
66- **Click a clip** to select it. A bar below the timeline then sets its volume with a stepped
67 slider (0–100% in steps of 10, with dB), applies its track and volume to every occurrence of that
68 sound effect, or resets it. Double-click a clip to jump to it.
69- **Drag a clip** up or down to move it to another track, or press **↑ / ↓** while it is selected.
70 ↓ on the last track adds a new one. Esc deselects.
71- **Collapse** the tracks with the *Audio tracks* toggle (or **A**) to get the space back. The
72 timeline then shows only the ruler and a tick wherever a sound effect fires.
73​
74A sound effect plays at *asset volume × clip volume × track volume*. Changes apply to sounds
75that are already playing, without restarting them. The mix is saved to
76`<project>/.rive-preview/mix.json`, so it survives reloads and rebuilds. Each clip is keyed by
77artboard, animation, event name and occurrence (`["Artboard","Bounce","whoosh",1]`), so retiming a
78keyframe keeps its settings. The preview never changes the Rive project. To keep the levels,
79the agent can read them with the `get_audio_mix` MCP tool. They are also attached to every
80feedback bundle that has a non-default mix, with the resulting volume for each sound effect.
81​
82## Screenshots, notes and the coding agent
83​
84Press **S** (or the camera button) to screenshot the frame under the playhead. The panel on
85the right lists every screenshot with its timecode and a note field: write what should change,
86and edit it as often as you like (notes save as you type; Esc leaves the field). Click a
87thumbnail or its timecode to jump back to that frame. When you are done, add an optional
88overall note and press **Send to agent** (Cmd+Enter in the overall note does the same).
89​
90Sending writes a bundle to `<project>/.rive-preview/feedback/<date_time>/`:
91`feedback.md` (notes, timecodes and image paths), `feedback.json`, and the PNGs, each cropped to
92the artboard. The panel then says whether the agent is listening for it (it picks the bundle up
93right away) or not (paste the ready-made prompt, which is copied to the clipboard, into your
94agent chat), and shows when the agent has read the bundle. `.rive-preview/` gets its own `.gitignore`, so nothing in it is committed.
95For a bare `.riv`, everything goes in `.rive-preview/<file>.riv/` beside it, so several `.riv` files
96in one folder keep their screenshots apart.
97​
98### Waking the agent: `wait-feedback`
99​
100Sending only writes the bundle. A coding agent that has finished its turn won't notice it, so
101the agent listens with a background command:
102​
103```bash
104rive-video-preview wait-feedback . # or path/to/project, or file.riv
105rive-video-preview wait-feedback . --timeout 30m # give up after 30 minutes (exit 124)
106```
107​
108It blocks until there is an unread bundle (or returns at once if one is already waiting),
109prints it (`feedback.md` with the notes, timecodes, artboard/animation and audio mix, plus every
110image path), marks it read and exits 0. Claude Code re-invokes the agent when a background
111command exits, so an agent that starts this with `run_in_background` after showing you the
112player is woken by your **Send to agent**, and its session stays free in the meantime. It reads
113the bundles from disk, so the player does not have to be running. `--no-mark-read` leaves them
114unread. Exit codes: 0 feedback, 124 timeout, 130 interrupted (Ctrl-C), 1 error.
115​
116While it (or the MCP tool `wait_for_feedback`) waits, it keeps a heartbeat file in
117`.rive-preview/listeners/`. That is how the player knows whether the agent is listening.
118Each bundle goes to exactly one consumer: whoever delivers it first takes a claim on it
119(`claimed.json` in the bundle folder), so two waiters, or a waiter and the MCP server, never
120both hand the same feedback to an agent.
121​
122### MCP server
123​
124`rive-video-preview mcp` is a stdio MCP server that gives the agent the bundles, images included:
125​
126| Tool | |
127|---|---|
128| `get_feedback` | unread bundles (notes, timecodes, artboard/animation, images); marks them read |
129| `wait_for_feedback` | blocks the agent until you press Send to agent (default timeout 600s), then returns it; `wait-feedback` in the background is usually better |
130| `seek_player` | moves the open player to a time, e.g. to show the frame it changed |
131| `get_audio_mix` | the tracks and per-sound-effect levels set in the player, and the level each plays at |
132​
133```bash
134claude mcp add rive-preview -- rive-video-preview mcp # Claude Code, project in cwd
135claude mcp add rive-preview -- rive-video-preview mcp path/to/project
136```
137​
138```json
139{ "mcpServers": { "rive-preview": { "command": "rive-video-preview", "args": ["mcp"] } } }
140```
141​
142It finds the project from the tool's `project` argument, the dir given after `mcp`, a
143`rive.yaml` at or above the working directory, one directly below it, or the only running player.
144It reads bundles from disk, so the player does not have to be running; only `seek_player` needs it.
145Agents without MCP can use `wait-feedback`, or read the `feedback.md` path from the copied prompt.
146​
147## Agent skill
148​
149The repo ships an [Agent Skill](https://vercel.com/docs/agent-resources/skills) that teaches coding
150agents to start the player, point you at moments, listen for the screenshots and notes you send,
151and carry over the audio levels you set.
152Install it with the `skills` CLI:
153​
154```bash
155npx skills add fulopkovacs/rive-preview-player # into the current project
156npx skills add fulopkovacs/rive-preview-player -g # for every project
157```
158​
159The skill only covers how to use the tool. You still need the CLI on PATH (see Install) and the
160MCP server registered for the agent (see MCP server above).
161​
162## Snippet for a project's AGENTS.md
163​
164```md
165## Showing the user a video preview
166​
167- Run `rive-video-preview .` in the background to open a scrubbable player with sound.
168 It rebuilds on save, so start it once and leave it running.
169- To point the user at a moment, run `rive-video-preview . --at <time>` (12.5, 1:02.25,
170 f741). This moves the playhead of the player that is already open.
171- Timecodes the user pastes look like `00:12.350 (frame 741)`, which is seconds into
172 the animation and the frame at its fps.
173- The user can screenshot frames, add notes and press "Send to agent". To hear it, run
174 `rive-video-preview wait-feedback .` in the background after showing the player and after
175 each round of fixes: it exits with the feedback (notes, timecodes, image paths, audio mix)
176 when the user sends it, and marks it read. Start it again after handling the feedback. Only
177 tell the user you'll pick feedback up automatically while it is running.
178- Otherwise read it with the `get_feedback` MCP tool, or from
179 `.rive-preview/feedback/*/feedback.md`.
180- The user can set sound-effect levels in the player. The project is unchanged; read them with
181 the `get_audio_mix` MCP tool or from `.rive-preview/mix.json` to carry them over.
182```
183​
184## Limits
185​
186- Audio is synced only for `AudioEvent`s keyed on the animation timeline, which is how
187 video scenes are built. A sound fired by a state machine transition or a script is not
188 played.
189- The player bypasses the state machine and drives the chosen animation directly, so
190 inputs, listeners and data-bound logic do not run. Use `rive .` to test interactivity.
191- For a bare `.riv` there is no project to inspect, so the player reads the artboards,
192 animations and `AudioEvent` keyframes from the file itself (`lib/riv-audio.mjs`). The property
193 types it needs come from `lib/riv-schema.json`; regenerate that with
194 `node scripts/gen-riv-schema.mjs` after a Rive CLI update. If the file cannot be read that
195 way, the duration is measured, the fps is assumed to be 60, and there is no audio timing.
196- Scripted (Luau) projects may fail to load: web runtimes reject the unsigned scripts
197 that local builds carry.
198​
199## Install
200​
201```bash
202pnpm install && pnpm link --global # puts `rive-video-preview` on PATH
203```