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

README.md

203 lines11.0 KB

rive-video-preview

Unofficial project. This is an independent, community-made tool. It is not affiliated with, endorsed by, or supported by Rive. "Rive" is a trademark of its respective owner.

https://github.com/user-attachments/assets/be18bae0-6259-4aae-89fc-0f8c92fcea6c

A video-style preview player for Rive CLI projects: a scrubbable timeline, synced audio, frame stepping and copyable timecodes. It runs in a resizable Chrome app window.

rive-video-preview                      # preview the project in the current directory
rive-video-preview path/to/project      # …or another project
rive-video-preview build/scene.riv      # …or a prebuilt .riv
rive-video-preview . --at 12.5          # jump to 12.5s (also 1:02.25, f741)
rive-video-preview . --stop             # stop the player for this project

How it works

  1. rive . --once --format=json builds an unsigned .riv (about 0.7s). No account and no upload.
  2. rive inspect . --json supplies the timeline: artboards, animations, fps and work area, plus every AudioEvent keyframe (KeyFrameCallback) with its asset and volume.
  3. A local server (127.0.0.1, port 4810+) serves the player. The page draws frames with @rive-app/webgl2-advanced, using LinearAnimationInstance.time and apply(), so any frame can be shown exactly.
  4. Audio bytes come out of the .riv through a custom asset loader. The runtime's own audio stays silent. Each sound plays through Web Audio, scheduled against the playhead, so sounds already under way when you press play start partway through, at the correct offset.
  5. Saving any project file (gen/build.py writing scene.rml counts) triggers a rebuild, and the window reloads in place without moving the playhead. A build error appears over the stage, and the player keeps showing the last good build.

Running the command a second time for the same project reuses the player that is already running. With --at, the open window jumps to that time.

Player

Key
Space / Kplay / pause
← / →step one frame · Shift: one second
Home / Endstart / end (of the in–out range if set)
I / O / Xset in point / set out point / clear (playback loops inside the range)
Ccopy timecode: 00:12.350 (frame 741)
Shift+Ccopy range: 00:10.000–00:12.500 (frames 600–750)
Ggo to time (or double-click the timecode)
L / M / Floop / mute / fullscreen
Sscreenshot the current frame and open its note
Nshow / hide the screenshots & notes panel
↑ / ↓move the selected sound effect up / down a track
Ahide / show the audio tracks

To copy the playhead time you can also click the timecode. Each copied timecode is also printed in the terminal running the player. Scroll on the timeline to zoom, Shift-scroll or a horizontal scroll pans, and a double-click on the ruler resets the zoom.

Audio tracks and sound-effect levels

Below the stage, every sound effect (each AudioEvent keyframe) is a clip on an audio track, with its waveform drawn at the level it plays at.

  • + Track adds a track, up to 3. Each track has a name, M (mute), S (solo), a volume slider (0–150%, double-click resets) and a remove button. Removing a track moves its sound effects to the track above it.
  • Click a clip to select it. A bar below the timeline then sets its volume with a stepped slider (0–100% in steps of 10, with dB), applies its track and volume to every occurrence of that sound effect, or resets it. Double-click a clip to jump to it.
  • Drag a clip up or down to move it to another track, or press ↑ / ↓ while it is selected. ↓ on the last track adds a new one. Esc deselects.
  • Collapse the tracks with the Audio tracks toggle (or A) to get the space back. The timeline then shows only the ruler and a tick wherever a sound effect fires.

A sound effect plays at asset volume × clip volume × track volume. Changes apply to sounds that are already playing, without restarting them. The mix is saved to <project>/.rive-preview/mix.json, so it survives reloads and rebuilds. Each clip is keyed by artboard, animation, event name and occurrence (["Artboard","Bounce","whoosh",1]), so retiming a keyframe keeps its settings. The preview never changes the Rive project. To keep the levels, the agent can read them with the get_audio_mix MCP tool. They are also attached to every feedback bundle that has a non-default mix, with the resulting volume for each sound effect.

Screenshots, notes and the coding agent

Press S (or the camera button) to screenshot the frame under the playhead. The panel on the right lists every screenshot with its timecode and a note field: write what should change, and edit it as often as you like (notes save as you type; Esc leaves the field). Click a thumbnail or its timecode to jump back to that frame. When you are done, add an optional overall note and press Send to agent (Cmd+Enter in the overall note does the same).

Sending writes a bundle to <project>/.rive-preview/feedback/<date_time>/: feedback.md (notes, timecodes and image paths), feedback.json, and the PNGs, each cropped to the artboard. The panel then says whether the agent is listening for it (it picks the bundle up right away) or not (paste the ready-made prompt, which is copied to the clipboard, into your agent chat), and shows when the agent has read the bundle. .rive-preview/ gets its own .gitignore, so nothing in it is committed. For a bare .riv, everything goes in .rive-preview/<file>.riv/ beside it, so several .riv files in one folder keep their screenshots apart.

Waking the agent: wait-feedback

Sending only writes the bundle. A coding agent that has finished its turn won't notice it, so the agent listens with a background command:

rive-video-preview wait-feedback .                  # or path/to/project, or file.riv
rive-video-preview wait-feedback . --timeout 30m    # give up after 30 minutes (exit 124)

It blocks until there is an unread bundle (or returns at once if one is already waiting), prints it (feedback.md with the notes, timecodes, artboard/animation and audio mix, plus every image path), marks it read and exits 0. Claude Code re-invokes the agent when a background command exits, so an agent that starts this with run_in_background after showing you the player is woken by your Send to agent, and its session stays free in the meantime. It reads the bundles from disk, so the player does not have to be running. --no-mark-read leaves them unread. Exit codes: 0 feedback, 124 timeout, 130 interrupted (Ctrl-C), 1 error.

While it (or the MCP tool wait_for_feedback) waits, it keeps a heartbeat file in .rive-preview/listeners/. That is how the player knows whether the agent is listening. Each bundle goes to exactly one consumer: whoever delivers it first takes a claim on it (claimed.json in the bundle folder), so two waiters, or a waiter and the MCP server, never both hand the same feedback to an agent.

MCP server

rive-video-preview mcp is a stdio MCP server that gives the agent the bundles, images included:

Tool
get_feedbackunread bundles (notes, timecodes, artboard/animation, images); marks them read
wait_for_feedbackblocks the agent until you press Send to agent (default timeout 600s), then returns it; wait-feedback in the background is usually better
seek_playermoves the open player to a time, e.g. to show the frame it changed
get_audio_mixthe tracks and per-sound-effect levels set in the player, and the level each plays at
claude mcp add rive-preview -- rive-video-preview mcp            # Claude Code, project in cwd
claude mcp add rive-preview -- rive-video-preview mcp path/to/project
{ "mcpServers": { "rive-preview": { "command": "rive-video-preview", "args": ["mcp"] } } }

It finds the project from the tool's project argument, the dir given after mcp, a rive.yaml at or above the working directory, one directly below it, or the only running player. It reads bundles from disk, so the player does not have to be running; only seek_player needs it. Agents without MCP can use wait-feedback, or read the feedback.md path from the copied prompt.

Agent skill

The repo ships an Agent Skill that teaches coding agents to start the player, point you at moments, listen for the screenshots and notes you send, and carry over the audio levels you set. Install it with the skills CLI:

npx skills add fulopkovacs/rive-preview-player        # into the current project
npx skills add fulopkovacs/rive-preview-player -g     # for every project

The skill only covers how to use the tool. You still need the CLI on PATH (see Install) and the MCP server registered for the agent (see MCP server above).

Snippet for a project's AGENTS.md

## Showing the user a video preview

- Run `rive-video-preview .` in the background to open a scrubbable player with sound.
  It rebuilds on save, so start it once and leave it running.
- To point the user at a moment, run `rive-video-preview . --at <time>` (12.5, 1:02.25,
  f741). This moves the playhead of the player that is already open.
- Timecodes the user pastes look like `00:12.350 (frame 741)`, which is seconds into
  the animation and the frame at its fps.
- The user can screenshot frames, add notes and press "Send to agent". To hear it, run
  `rive-video-preview wait-feedback .` in the background after showing the player and after
  each round of fixes: it exits with the feedback (notes, timecodes, image paths, audio mix)
  when the user sends it, and marks it read. Start it again after handling the feedback. Only
  tell the user you'll pick feedback up automatically while it is running.
- Otherwise read it with the `get_feedback` MCP tool, or from
  `.rive-preview/feedback/*/feedback.md`.
- The user can set sound-effect levels in the player. The project is unchanged; read them with
  the `get_audio_mix` MCP tool or from `.rive-preview/mix.json` to carry them over.

Limits

  • Audio is synced only for AudioEvents keyed on the animation timeline, which is how video scenes are built. A sound fired by a state machine transition or a script is not played.
  • The player bypasses the state machine and drives the chosen animation directly, so inputs, listeners and data-bound logic do not run. Use rive . to test interactivity.
  • For a bare .riv there is no project to inspect, so the player reads the artboards, animations and AudioEvent keyframes from the file itself (lib/riv-audio.mjs). The property types it needs come from lib/riv-schema.json; regenerate that with node scripts/gen-riv-schema.mjs after a Rive CLI update. If the file cannot be read that way, the duration is measured, the fps is assumed to be 60, and there is no audio timing.
  • Scripted (Luau) projects may fail to load: web runtimes reject the unsigned scripts that local builds carry.

Install

pnpm install && pnpm link --global    # puts `rive-video-preview` on PATH