Skip to content

Add type:playwright visual source for browser-based capture #16

@jmjava

Description

@jmjava

Context

We have a working Playwright spike in the course-builder repo (tools/courseforge/demo-capture.py) that captures a full-workflow demo video of the CourseForge A1 LiDAR UI using Playwright's built-in video recording.

Spike results (validated in course-builder)

  • Playwright records 1920x1080 WebM at 25fps with smooth mouse automation
  • ffmpeg re-muxes to H.264 MP4 (1.5 Mbps, yuv420p) — fully compatible with the existing compose pipeline
  • Video + audio mux confirmed: H.264 video + AAC audio combine cleanly via ffmpeg -c:v copy -c:a aac
  • The spike script runs headless on Ubuntu and produces ~3.5 MB for an 18-second demo

Proposal

Add type: playwright as a new visual source type alongside the existing type: manim and type: vhs sources.

Integration points

  1. config.py — Accept type: playwright in visual_map entries with fields:

    • script: path to a Python capture script (like the spike's demo-capture.py)
    • url: target URL for the browser session
    • viewport: optional {width, height} override (default 1920x1080)
  2. compose.py — In compose_segments(), dispatch type: playwright segments to a new PlaywrightRunner that:

    • Launches headless Chromium via Playwright
    • Executes the user-provided script (or a generic "navigate + wait" default)
    • Returns the recorded video path for ffmpeg composition
  3. CLI — Add docgen playwright subcommand for standalone capture (useful for testing scripts before full compose)

  4. pyproject.toml — Add playwright to project dependencies

Reference

  • Spike script: menkelabs/course-builder@feature/playwright-capture-spiketools/courseforge/demo-capture.py
  • Milestone 2 already mentions "headless render — capture slide transitions as MP4 using Playwright or a headless browser"
  • Existing pytest-playwright in dev deps confirms Playwright is already in the toolchain

Acceptance criteria

  • docgen playwright --script my_script.py --url http://localhost:3300 produces an MP4
  • type: playwright segments compose correctly with narration audio via the existing pipeline
  • Headless mode works on Ubuntu (CI-compatible)
  • Documentation updated with Playwright visual source examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions