This module was responsible for recording online game replays using Puppeteer and FFmpeg.
- Worker (
apps/backend/src/workers/screencast.ts): Usedpuppeteer-streamor Docker (X11 + FFmpeg) to capture browser tabs. - Recording Flow:
- Resolved target URL.
- Launched Puppeteer with specific viewport (1920x1080).
- Injected CSS/JS to hide UI bars and lock scrolling.
- Clicked Play button (via ID or text fallback).
- Streamed video/audio to FFmpeg.
- Encoded to MP4 and uploaded to Cloudflare R2 via AWS SDK.
- Live Preview (
apps/backend/src/lib/live-preview-store.ts): Stored JPEG frames in memory for real-time viewing in the frontend. - Queue (
BullMQ): Managed jobs for asynchronous recording.
- Viewport/Cropping: Chrome's tab capture is often limited to 1080p regardless of viewport size. CSS
zoomortransform: scalewere used to fit 1440p design into 1080p frame. - Interactions: Clicks on toggle-style Play buttons needed precise handling via
evaluateto avoid re-pausing or missing coordinates due to zoom. - Network/SSL:
curlwas unstable for R2 uploads on some systems; native AWS SDK was more reliable. - Jerking: Initial capture frames can be unstable; a "warm-up" period or removal of JS scroll-locks helped stabilize the image.
puppeteerpuppeteer-streamaws-sdk(S3 client)ffmpeg(system dependency)