---
name: demo-video
description: Produce a feature demo video from a scripted agent-browser recording of a web app in a sandbox or test environment. Output is a beat-locked 30 s directed cut or 60 s tour in a flat, light house style, with plain-language caps captions, original synth music, wow/ding/vine-boom/FAH sound effects and a TikTok-voice voiceover, plus an optional annotated screenshot walkthrough page. Delivered as an mp4 and/or a static HTML page. Use when the user asks for a demo video, hype video, feature walkthrough recording, screen-recorded demo, or annotated screenshots of a product change. Built around Salesforce (sf CLI login), and works for any browser app.
---

# Demo video

Built for one Salesforce feature (a button for each performance guarantee (PG) type on a task record). The two examples are the cuts that shipped, with the org's hostname, record IDs and numbers replaced by placeholders, so treat them as patterns to copy, not scripts to run as-is. Everything in `scripts/`, `templates/` and `assets/` is general.

- `examples/directed-30s/`: **30 s directed cut.** One idea: "we had the tasks but no easy way to update the reports. Now we do." Problem + FAH, fix + WOW, then four clips on how it works. Mixes a read-only take with the tour's take and zooms in with crops.
- `examples/tour-60s/`: **60 s tour.** Every button variant the feature has, one clip each (4 buttons, 3, 2, none by design), from one recording.

Start from the directed shape unless the user wants every variant shown. Copy the closer example and edit it; don't start from a blank file.

| Path | What it does |
|---|---|
| `scripts/lib_browser.sh` | Helpers for a take script: login, 1920x1080 recording, ref-based click/hover/type/select, captions and screenshots logged with raw timestamps |
| `scripts/render_cards.sh` | HTML cards → 1920x1080 PNGs through agent-browser. Copies `theme.css` next to the HTML if it's missing. |
| `scripts/music.py` | Original 128 BPM synth bed. `--beats`, `--drop`, `--outro` set the length and where the drop and outro fall. |
| `scripts/tts.py` | TikTok voice (`en_us_002`) clips, cached by text in `~/.cache/demo-video-tts` (`TTS_CACHE` overrides) |
| `scripts/compose.py` | Spec-driven cut: cards, framed clips with captions, music, SFX, voiceover → 5 fps mp4 |
| `scripts/check.sh` | ffprobe, 1 fps contact sheet, loudness and peak, speech-to-text of the mix; raw sheets for picking clip times |
| `templates/theme.css` | The house style for cards and clip frames. Light by default; `body.dark` for dark. |
| `templates/cards.html` | Card building blocks: problem headline, big stat, real UI crop, outro |
| `templates/walkthrough.html` | Skeleton for the annotated screenshot page: header, video, one `figure.step` per screenshot |
| `assets/sfx/` | `wow.mp3`, `ding.mp3`, `boom.mp3` (vine boom), `fah.mp3`, all supplied by the user |

## Install and requirements

Unzip so this folder sits where your agent reads skills, for example `.cursor/skills/demo-video/` or `.claude/skills/demo-video/` in a repo, or `~/.cursor/skills/demo-video/` for every project. Every command below uses `S` for that folder:

```bash
S=/path/to/demo-video        # e.g. S=$PWD/.cursor/skills/demo-video
```

| Tool | Used for | Install |
|---|---|---|
| [agent-browser](https://www.npmjs.com/package/agent-browser) (tested with 0.42) | Scripted takes, recording, card rendering | `npm i -g agent-browser && agent-browser install` |
| ffmpeg + ffprobe (with libx264, `drawtext`) | Compose and checks | `apt install ffmpeg` / `brew install ffmpeg` |
| Python 3.10+ with `numpy`, `scipy` | `music.py`; `compose.py` is stdlib only | `pip install numpy scipy` |
| `faster-whisper` | Speech-to-text check (auto-installed by `check.sh`; downloads ~140 MB once) | `pip install faster-whisper` |
| Inter font | Cards, captions, raw-sheet timestamps | [rsms.me/inter](https://rsms.me/inter/), then `fc-cache -f` |
| Salesforce CLI (`sf`), optional | `login <alias>` in `lib_browser.sh` | Only for Salesforce. For another app, replace `login` with a step that opens a signed-in URL. |

The voiceover uses a free, unofficial TikTok TTS proxy (`ottsy.weilbyte.dev`), so it needs network access and can go down; see Papercuts for the fallback. The four sound effects in `assets/sfx/` are common meme clips; check that your team is fine with them before you publish a video outside the company.

Quick smoke test after install, no recording needed:

```bash
W=/tmp/demo-smoke && mkdir -p $W && cp $S/templates/cards.html $S/examples/directed-30s/btnbar.png $W/
bash $S/scripts/render_cards.sh $W/cards.html $W c1 c2 c3      # writes c1.png..c3.png
python3 $S/scripts/music.py $W/music.wav --beats 64 --drop 16 --outro 56
```

## Step 0: Preflight with the user

Settle these before you record. Changing copy or sound after compose takes seconds. Changing the take means recording it again.

1. **Deliverables:** a 30 s directed cut (default), a 60 s tour, an annotated screenshot page, or a mix.
2. **Story:** research how the feature works before you write a word. Read the ticket's plan docs and the code on the feature branch (`git show origin/<branch>:<path>`; don't switch branches). The script should say *why* it works ("it matches the task's client, due date and PG type"), not only what's on screen.
   - Get real numbers from a read-only production query, and re-run it on the day of the cut. Say on the card where the number came from.
   - Directed cut: write one line per beat (shot, caption, voiceover). Cut every beat that doesn't serve the one idea.
   - Tour: list every variant the feature has, one clip each.
3. **Shape** (both examples use it): name the problem with a FAH, say "Now we do" over the fix with a WOW, show how it works, then land the payoff on the outro card.
4. **Audio:** music on by default. Voiceover is the TikTok voice saying the idea of a caption in a few words; it never reads slide text word for word. Keep sounds sparse (see Sound).
5. **Delivery:** where the video goes (chat, Slack, a static page) and any file size limit there.

Show the user the full script as a table (time, shot, caption, voiceover, sound) and get a yes before you record or compose.

## House style

The look is flat and plain, so the product is the most colorful thing on screen.

- Light background by default (`THEME = "dark"` and `<body class="dark">` for dark). One typeface (Inter), black ink, one blue accent, red for the problem phrase and green only for success.
- Cards are left-aligned on a 200 px margin: a small gray label, one headline, at most one plain supporting line, a hairline footer with the ticket and the data source.
- Clips sit in a 1520x855 window with 10 px rounded corners and a 1 px gray border. The caption sits below the window, not on top of the product.
- Show real UI. If a card needs to show the product, crop it from the recording (`.shot-inline`); never rebuild Salesforce UI in HTML.
- **Banned:** gradients, glows, drop shadows, emoji, arrows used as words (→), stock icons, and progress bars or chapter markers baked into the frames (Cursor's player adds its own).

## Copy: plain language, hype in caps

Follow 18F plain language: short sentences, common words, active voice, "you". Hype comes from short, concrete, confident phrasing plus caps. It never comes from jargon or exclamation marks.

- Write captions and cards in sentence case. `theme.css` sets the caption headline in caps, so the source stays readable and easy to edit.
- Caption headline: 3–7 words that name the problem or the payoff. Sub-line: one plain sentence of fact.
- Voiceover: the idea of the caption in about 3–7 words. Don't read the sub-line.
- One colored phrase per card at most.
- Read every rendered card at full size. If a line wraps and leaves one word alone, rewrite the copy rather than shrinking the font.

| Don't | Do |
|---|---|
| `4 PG TYPES DUE → 4 BUTTONS` | `Four PG types due, four buttons` |
| `NO SCORE YET? HINT, NOT A WALL.` | `No score yet? You get help` |
| `Leverage intelligent report matching` | `It knows which reports` |
| `Seamlessly streamline quarterly PG workflows!` | `Fill it in once` |
| `CSMs were burdened with manual report remediation` | `We had all these PG tasks. No easy way to update the reports.` |
| Sub-line: `Checked on the screen and by a validation rule.` | Sub-line: `The screen and a validation rule both stop them.` |
| Voiceover reading the caption: "Each PG type gets its own screen. ROI shows its contract, target and tips." | Voiceover saying the idea: "Each type gets its own screen." |

## Sound

| Sound | Use it for | Gain |
|---|---|---|
| `fah` | Something going wrong: the problem card, a failing screen, a validation error | +12 dB (the clip is ~11 dB quieter than the wow) |
| `wow` | The fix. When there's a FAH, the wow lands on the fix that answers it, usually on the drop. | +3 dB |
| `boom` | A sudden reveal: a hard cut onto the frame where the answer appears | −6 dB (the clip is ~14 dB hotter) |
| `ding` | A save or completion visibly landing (success screen, green toast) | +6 dB |

- **FAH → WOW is a pair.** Show the problem with a FAH, cut to the fix with a wow, and have the voiceover name the fix right after ("Now we do."). Use one pair per cut. A FAH without a fix leaves the video on the problem.
- Budget: a 30 s cut gets the pair, one boom and one ding. A 60 s cut gets the pair and two dings. The first tour (3 wows, 3 dings, 18 voiceover lines) came back as "a bit too much talking and dinging."
- Keep sounds at least 1 s apart. A boom and a wow on the same reveal is one too many; drop the boom.
- Voiceover starts ≥1 s after a wow or FAH and ≥0.4 s after a boom, so the words aren't buried.

## Step 1: Data safety (sandbox only, never production)

A take that saves anything edits real sandbox records. The commands are Salesforce; the steps apply to any app. A read-only take (like the directed example's `take.sh`) skips this step.

1. Pick demo records that already show each variant. Note their IDs.
2. Snapshot every field the take will touch:

```bash
sf data query -o <sandbox-alias> -r csv \
  -q "SELECT Id, Actual_Score__c, Actual_Reporting_Date__c, Notes_Comments__c FROM PG_Report__c WHERE Id IN ('a1X...','a1X...')" \
  > /tmp/demo/snapshot.csv
```

3. Write `reset.apex` to blank those fields and reopen the parent task. Run it before **every** take: `sf apex run -o <sandbox-alias> -f /tmp/demo/reset.apex`.
4. After the final take, build `restore.apex` from the snapshot CSV, run it, re-query to a second CSV, and `diff` the two. Tell the user the diff came back clean.

Never impersonate users (Login-As) and never reassign records to get a shot.

## Step 2: Record the take

```bash
mkdir -p /tmp/demo/src && cp $S/examples/directed-30s/take.sh /tmp/demo/src/   # rewrite it for the new feature
OUT=/tmp/demo/take1 bash /tmp/demo/src/take.sh
```

A take script sources `lib_browser.sh` and reads like this:

```bash
source "$S/scripts/lib_browser.sh"
login my-sandbox                                          # sf org open frontdoor URL; swap for your app's login
goto "$LIST" 'searchbox "Search this list'                # open, then wait for a ref
start_recording                                           # sets 1440x810 @1.333 = 1920x1080, records with cursor
cap "Find Lakeshore's quarterly PG Status task."          # logs raw time to captions.tsv
typein 'searchbox "Search this list' "Lakeshore"; $A press Enter >/dev/null
click 'link "PG Status due 2026-11-10 - Lakeshore'
waitref 'button "Update ROI"' >/dev/null; pause 2.5
shot 01-lakeshore-task "Lakeshore PG Status task with its type buttons."
hover 'button "Update System Uptime"'; pause 1.3
stop_recording                                            # writes $OUT/raw.mp4
```

- Pace for a human: 1.2–1.6 s per hover and 2.5–4 s on every screen worth reading. compose.py can speed clips up but can't invent frames you didn't record.
- Call `cap "..."` at every beat. `captions.tsv` is how you find clip times later.
- Call `shot <nn-slug> "<caption>"` at each state you want on the walkthrough page, after `rest` moves the cursor out of the way.
- Debug selectors in a dry run without `start_recording`. Then `grep MISSING: $OUT/log.txt`: any line there is a timed-out selector and dead air in the take.
- Find selectors with `agent-browser --session demo snapshot -i | grep -i <word>`, and pass role plus quoted name: `'button "Update ROI"'`.

## Step 3: Pick clip times

```bash
bash $S/scripts/check.sh /tmp/demo/take1/raw.mp4 /tmp/demo/take1/raw.mp4   # also writes timestamped 1 fps raw sheets
```

- Use `captions.tsv` for rough starts and the raw sheets for exact ones.
- Start each clip **after** the page or flow finishes loading. Spinners and half-drawn pages look broken at 1.5–2x.
- Cue a ding on the frame where the success state appears ("Saved 2 reports", the green toast). Find it in the raw sheet and cue it with `("raw", 33.0)`.
- Measure crops on a gridded frame, then multiply by 1.875 to get source pixels:

```bash
ffmpeg -nostdin -y -ss 15 -i raw.mp4 -frames:v 1 -vf "scale=1024:-1,drawgrid=w=64:h=64:color=red@0.4" /tmp/demo/grid.png
```

## Step 4: Cards, music, spec

```bash
W=/tmp/demo/directed
mkdir -p $W && cp $S/examples/directed-30s/{cards.html,spec.py} $W/     # edit copy, paths, TIMELINE
ffmpeg -nostdin -y -ss 13.5 -i $W/take/raw.mp4 -frames:v 1 -vf crop=990:70:902:205 $W/btnbar.png   # real UI for a card
bash $S/scripts/render_cards.sh $W/cards.html $W c1 c2
python3 $S/scripts/music.py $W/music.wav --beats 64 --drop 16 --outro 56      # pip install numpy scipy if missing
```

**Cards** come from `templates/cards.html`. Each `.card` div has an id; `render_cards.sh` writes `<id>.png` into the folder you name, which must be the spec's `CARDS_DIR`. Building blocks: `.label`, `h1`, `.stat` (one big number), `p`, `.bad`/`.good`/`.accent` spans, `.foot`, `.shot-inline img`. Images a card uses (like `btnbar.png`) sit next to `cards.html`.

**Beat math.** Every length is in beats. At 128 BPM one beat is 0.46875 s; 64 beats is 30 s and 128 beats is 60 s. compose.py fails if the TIMELINE doesn't add up to `DURATION`. Keep `--drop` a multiple of 4, and put the "Now we do" moment on it.

| Format | music.py | TIMELINE |
|---|---|---|
| 30 s directed | `--beats 64 --drop 16 --outro 56`, `DURATION = 30.0` | clip 8 + problem card 8, then 40 beats of clips (5 clips of 6–10, the first on the drop), outro card 8 |
| 60 s tour | defaults (`--beats 128 --drop 16 --outro 116`), `DURATION = 60.0` | cards 4 + 4 + 8, "Now" card 8 on the drop, 92 beats of clips (13 clips of 6–10), outro card 12 |

Clip speed is raw length ÷ slot length. Keep it under about 2.5x.

**Spec reference** (`spec.py` is plain Python):

| Name | Meaning |
|---|---|
| `RAW` | Default recording for clips |
| `OUT`, `MUSIC`, `CARDS_DIR` | Output mp4, music wav, folder holding `<card id>.png` |
| `DURATION` | 30.0 or 60.0 (default 60.0) |
| `TIMELINE` | Ordered list. A card is `("card", "c1", beats)`. A clip is `(raw_start, raw_end, beats, "Caption", "Sub-line.")`, plus an optional `{"raw": other_recording, "crop": (x, y, w, h)}`. |
| `SFX` | `(cue, offset_s, "wow"/"ding"/"boom"/"fah", gain_db)` |
| `VOICEOVER` | `(cue, offset_s, "Line.")` |
| Optional | `THEME` (`"light"`), `VOICE` (`"en_us_002"`), `VO_GAIN_DB` (8), `DUCK` (0.35), `VO_MAX_TEMPO` (1.45), `CRF` (16), `WORK` |

**Cues**, each with a seconds offset:

| Cue | Points at |
|---|---|
| `4.2` | Absolute seconds in the cut |
| `("card", "c1")` | Start of that card |
| `("seg", "Now we do")` | Start of the first clip whose caption starts with this text (case-sensitive, first match wins) |
| `("raw", 33.0)` / `("raw", 15.0, NEW)` | That moment of the recording, through the clip's speed-up; pass the recording when it isn't `RAW` |
| `("outro",)` | Start of the last card |

**Crops** are in source pixels (1920x1080) and must be about 16:9, because the crop fills the 1520x855 window. compose.py rejects a crop that isn't.
- A button bar near the top can't sit in the middle of a 16:9 crop. Start the crop at y=0 so the bar lands in the top third (`BUTTONS = (806, 0, 1099, 618)`).
- A modal crop should hug the modal (`MODAL = (349, 174, 1224, 688)`). Tall flow screens already fill the frame; leave those uncropped.
- A hard cut that opens on the frame where a screen finishes loading reads as a reveal. That's where a boom goes.

A good TIMELINE entry, from the directed example:

```python
(14.9, 20.5, 6, "Now we do", "One button for each PG type due on the task.", {"raw": NEW, "crop": BUTTONS}),
```

## Step 5: Compose and verify

```bash
python3 $S/scripts/compose.py $W/spec.py          # prints each VO window and SFX time; ~20 s for 30 s, ~40 s for 60 s
bash $S/scripts/check.sh $W/<out>.mp4
```

Read the printed VO and SFX times first. Any sound within 1 s of another, or inside a voiceover window, needs fixing before you look at the video.

Check all of these before you deliver:

- [ ] `duration=30.000000` (or 60), `r_frame_rate=5/1`, one video and one audio stream
- [ ] Contact sheet: no spinners, no half-loaded pages, no cursor parked over the thing a caption names
- [ ] One full-size frame from a card and one from a clip: rounded window corners, caption in caps below the window, no orphan words
- [ ] Integrated loudness about −13 to −15 LUFS, peak below 0 dBFS
- [ ] Transcript: every voiceover line appears near its cue. Homophones ("peachy" for "PG") are fine. A missing line is buried: raise `VO_GAIN_DB`, lower `DUCK`, or move the sound.

Grab full-size frames with:

```bash
ffmpeg -nostdin -y -v error -ss 12 -i $W/<out>.mp4 -frames:v 1 /tmp/demo/frame_12.png
```

## Step 6: Deliver

**The mp4.** Share the file directly. A 30 s cut is about 3.5 MB and a 60 s cut about 6.5 MB at 5 fps, crf 16.
- In a Cursor cloud agent, copy it to `/opt/cursor/artifacts/<snake_case_name>.mp4` and show it with `<video src="/opt/cursor/artifacts/<snake_case_name>.mp4"></video>`. Artifacts are immutable, so every new version needs a new filename (`..._v2.mp4`).
- Keep earlier versions under their own names so people can compare.

**Walkthrough page.** Build a self-contained folder: `index.html` from `templates/walkthrough.html`, `screenshots/` from `$OUT/shots`, `poster.png`, `demo.mp4`. Host it anywhere static (GitLab/GitHub Pages, S3, an intranet share).
- Many git hosts cap file size (GitLab push rules are often 5 MiB). Re-encode with `-crf 30 -tune stillimage` (a 217 s walkthrough went from 11 MiB to 4.2 MiB), or host the video elsewhere and link to it.

## Papercuts

Every one of these cost a retry while building the example cuts.

| Symptom | Cause and fix |
|---|---|
| **Recording** | |
| "My ..." lists and home-page tiles are empty | You're signed in as an admin or integration user, and the demo records belong to someone else. Record from an "All ..." list view. Don't impersonate users or reassign records for a shot. |
| List view opens in split view with a random record | Switch it once with "Select list display" → Table. Lightning remembers the choice for that list, so reopen the list URL afterwards. |
| Lightning date field won't clear | `fill ""` is ignored. Use `clearin` (click, Ctrl+A, Backspace, Tab). |
| A click on a radio or checkbox by its text misses | Use snapshot refs through the helpers, not visible-text clicks |
| Take has dead air | A selector timed out. `grep MISSING: $OUT/log.txt`, fix the ref, record again. |
| Cut shows a loading spinner | The clip starts before the flow loads. Move the start past the frame where the modal renders. |
| agent-browser warns that Chrome is out of date | Harmless; ignore it |
| **Cards and frames** | |
| Headless Chrome `--screenshot` hangs | Render through agent-browser in its own session (`render_cards.sh` uses `cards`, the take uses `demo`) |
| Edited card renders the old version | agent-browser serves a cached page for the same URL. `render_cards.sh` adds a cache-busting query param; always render through it. |
| Card renders unstyled (Times, black on white, all cards stacked) | `theme.css` isn't next to the HTML. `render_cards.sh` copies it if missing; if you edit `templates/theme.css`, delete the old copy first. |
| One word alone on the last line of a card | The copy is too long for 104 px. Rewrite the line shorter; don't shrink the font. |
| Card image missing | Images resolve relative to `cards.html`. Copy `btnbar.png` (or your crop) next to it. |
| `alphamerge` fails: "Input frame sizes do not match (1520x855 vs 1520x854)" | lavfi sources are yuv420p, which rounds odd heights down. compose.py builds the mask one row taller and crops it, and converts clips to rgba before scaling. Keep that if you change `WH`. |
| Crop looks stretched, or compose fails with "must be ~16:9" | The crop isn't 16:9. Fix the width or height: `h = round(w * 9 / 16)`. |
| **Audio** | |
| `VO '...' needs 1.46x to fit` | The line is longer than its slot (up to the next line's cue). Shorten it, start it earlier, or split it. A 3.75 s card holds about 8 words. |
| Sound under the first words of a voiceover line | Move the line: ≥1 s after a wow or FAH, ≥0.4 s after a boom. Or drop the sound. |
| Two sounds blur into one | They're under 1 s apart (the tour's save ding sat 0.9 s before a boom). Drop the less important one. |
| Music barely ducks under voiceover | `sidechaincompress` does little against the dense synth bed. compose.py uses an explicit volume envelope; tune `DUCK`. |
| Peaks above 0 dBFS after the limiter | `alimiter` auto-level is on by default and AAC overshoots. compose.py uses `level=disabled` and mixes −4 dB into a 0.7 ceiling. |
| TikTok proxy returns 307 HTML | `tiktok-tts.weilnet.workers.dev` moved to `ottsy.weilbyte.dev/api/generation`, which `tts.py` already uses |
| TikTok proxy down | It's a free, unofficial proxy. Cached lines still remix. For new lines, fall back to `pip install edge-tts` and `edge-tts --voice en-US-JennyNeural --rate=+15%`. |
| **Verifying** | |
| faster-whisper `metadata_errors` TypeError | PyAV version mismatch. `check.sh` feeds it raw float PCM instead of the file. |
| Transcript ends with words nobody said ("One, two, three") | Whisper hallucinates on the music outro. Ignore text after the last voiceover line. |
| First `check.sh` run is slow | It downloads the `base.en` model (~140 MB) once |
| **Shell and git** | |
| `while read` loop over ffmpeg calls skips lines | ffmpeg reads stdin. Always pass `-nostdin`. |
| A long compose looks hung | It isn't. A 60 s cut takes ~40 s on top of the voiceover fetch. Wait for the output path line. |
| Production query fails with "No such column" on a field that exists | Your user lacks field-level access. Use a number you can query, and don't put an unverified number on a card. |
| Push rejected for file size | Your git host's per-file limit. See Deliver. |
