Skip to main content
All posts
Guide

Make a product demo video with Claude and Playwright

Use Claude to write the script and Playwright to record it, then cut it with ffmpeg. The pipeline, the code shape, and the traps that cost us hours.

You can build a demo-video pipeline yourself in an afternoon. Getting it to produce videos you would publish takes longer. This is the shape that works, and the traps we hit building GetProductDemo.

The pipeline

  1. Read the page. Open the URL in Playwright and collect the heading and the visible buttons and links with their exact labels.
  2. Write the script. Give Claude the page facts and ask for four to seven spoken lines, each optionally tied to one control from that list. Use structured output so the reply is JSON you can validate, and reject any control that is not on the page.
  3. Voice every line. Generate one audio file per line and measure its length.
  4. Record. For each line, show the caption, wait about a third of the line, click the control, then hold until the line's audio would end.
  5. Cut. With ffmpeg, place each line's audio at the moment its caption appeared, trim the page load from the start, and encode H.264.

Trap 1: recording first, voicing second

If you record first and fit the voice afterwards, every slow page load squeezes a line. You end up speeding audio up or cutting it off. Voice first, then let the recording wait for the voice.

Trap 2: Playwright's default timeout after navigation

After a click that navigates, the old element is gone. Any later locator.evaluate() or isDisabled() on it waits for Playwright's default 30 seconds before failing. Our first videos had half a minute of dead air after every navigation. Pass an explicit short timeout to every call made after a click.

Trap 3: device scale factor does not upscale video

Setting deviceScaleFactor: 1.5 with recordVideo.size at 1920×1080 does not give you a sharp 1080p recording; Playwright records at the viewport's CSS size and pads the rest. Record a 1600×900 viewport and scale to 1080p in ffmpeg instead.

Trap 4: controls that repeat

Pages repeat their main call to action in the hero and the footer. If the script uses the same label twice, the second click often lands on a page where it no longer exists. Use each label once, and go back to the start page when a control is missing.

Trap 5: the model invents buttons

Even with the list in the prompt, a model will sometimes name a control that is not there. Check every control against the page's own list and drop the ones that do not match.

When to stop building

The pipeline above makes a decent one-minute demo. Logins with one-time codes, cookie banners, pages that render late, background music, zoom on clicks and social formats each add another week. If you would rather paste a URL, that is what GetProductDemo does.