Back to Opennhp

Capture Diagram Animations

docs/capture-diagrams.md

0.7.32.3 KB
Original Source

Capture Diagram Animations

{: .fs-9 }

Record the interactive SVG architecture diagrams as GIF and MP4 files. {: .fs-6 .fw-300 }


Overview

The project provides two capture scripts that use Puppeteer to record SVG animations from the VitePress documentation site and encode them into GIF and MP4 via ffmpeg.

ScriptTarget PageOutput Files
capture-arch.mjs/arch-demoarch-diagram.mp4, arch-diagram.gif
capture-claw-dhp.mjs/claw-dhp-democlaw-dhp-diagram.mp4, claw-dhp-diagram.gif

Prerequisites

  • Node.js (v18+)
  • Chrome or Chromium — auto-detected at common paths, or set the CHROME_PATH environment variable
  • ffmpeg — must be available on PATH

Install Dependencies

bash
cd docs
npm install

Usage

Step 1: Start the VitePress Dev Server

bash
cd docs
npm run dev -- --port 5180

Keep this terminal running.

Step 2: Run the Capture Script

Open a new terminal:

bash
cd docs

# Capture the NHP architecture diagram
node capture-arch.mjs

# Capture the OpenClaw + DHP architecture diagram
node capture-claw-dhp.mjs

Output files are written to docs/recordings/.

Configuration

Both scripts support environment variables for customization:

VariableDescriptionDefault
CAPTURE_URLFull URL of the target pagehttp://localhost:5180/<page>
CHROME_PATHPath to Chrome/Chromium executableAuto-detected

Example:

bash
CHROME_PATH=/usr/bin/chromium node capture-arch.mjs

Script Parameters

Default values are defined at the top of each script and can be edited directly:

Parametercapture-arch.mjscapture-claw-dhp.mjs
Viewport1200 x 8001920 x 1080
Duration8 seconds8 seconds
FPS3030
GIF scale width800px1920px
GIF palette colors128256

How It Works

  1. Puppeteer launches headless Chrome and opens the target VitePress page
  2. Waits for the Vue component to render (.arch-wrapper or .claw-dhp-wrapper)
  3. Pauses SVG animations and steps through the timeline frame-by-frame via svg.setCurrentTime()
  4. Takes a screenshot for each frame (240 frames = 8s at 30fps)
  5. Encodes the PNG sequence into MP4 (H.264) and GIF (two-pass with optimized palette) using ffmpeg
  6. Cleans up temporary frame files