Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Live Stream a Browser Tab to RTMP

Stream a tab live to RTMP endpoints like X Live, Twitch, or YouTube. Playwriter captures the page with CDP Page.startScreencast, the same pipeline used for recording, so the stream survives page navigation. Each JPEG frame is piped to an ffmpeg process that encodes in real time and pushes to your destinations.
No permission click is needed. It works in extension mode, direct CDP mode (PLAYWRITER_DIRECT), headless, and cloud browsers.
The executor and ffmpeg run inside the relay process, so the stream keeps running after the CLI exits. Render a web page, stream it for hours.

Requirements

  • ffmpeg installed and on PATH

Start streaming

The stream captures the session's state.page. Set it and navigate first, then start:
playwriter -s 1 -e "state.page = await context.newPage(); await state.page.goto('https://my-generated-content.example')" playwriter stream start -s 1 --rtmp rtmp://va.pscp.tv:80/x/<stream-key>
Simultaneous multi-streaming: repeat --rtmp. It uses ffmpeg's tee muxer, so one encode serves all destinations, and a dead endpoint doesn't kill the others:
playwriter stream start -s 1 \ --rtmp rtmp://va.pscp.tv:80/x/<x-stream-key> \ --rtmp rtmp://live.twitch.tv/app/<twitch-stream-key>

Monitor and stop

# Uptime, frames sent and captured, audio chunks, encoder fps, bitrate, dropped frames playwriter stream status -s 1 # Graceful stop: flushes the encoder and waits for ffmpeg to exit playwriter stream stop -s 1 # => Stream stopped after 3600s (108000 frames)

Options

FlagDefaultDescription
--rtmp <url>requiredRTMP destination with stream key, repeatable
--resolution <WxH>1920x1080Output resolution
--fps <n>30Output frame rate
--video-bitrate <kbps>9000X Live recommended; Twitch max is 6000
--keyframe-interval <s>3X Live recommended (and max); Twitch recommends 2
--audio-bitrate <kbps>128AAC 44100Hz stereo
--no-audiooffSkip page audio, sends a silent track (X Live requires an audio track)
--preset <name>veryfastx264 preset, only applies to libx264
--codec <name>autoAuto-detects hardware encoders (videotoolbox, nvenc, qsv, amf), falls back to libx264
Defaults match X Live's recommended encoder settings (1080p, 9000 kbps H.264, 30 fps, 3s keyframes, AAC 128k 44100Hz stereo). For Twitch use --video-bitrate 6000 --keyframe-interval 2.

Audio

Audio is on by default for streams. Playwriter injects a Web Audio tap in the page that captures <audio>, <video> and AudioContexts playing to the speakers, then muxes the PCM in ffmpeg.
  • No audio from cross-origin (out-of-process) iframes
  • An AudioContext graph wired before the stream starts is missed
  • The page can detect the patched audio APIs while streaming
With --no-audio (or audio: false) a silent track is sent instead.

Executor API

The same functionality is available inside execute code:
await stream.start({ page: state.page, rtmpUrls: ['rtmp://va.pscp.tv:80/x/STREAM_KEY'], resolution: '1920x1080', fps: 30, videoBitrateKbps: 9000, }) // => { startedAt, destinations } await stream.status({ page: state.page }) // => { streaming, startedAt, destinations, stats: { videoFrames, capturedFrames, audioChunks, ffmpegFps, ffmpegBitrateKbps, droppedFrames }, error? } await stream.stop({ page: state.page }) // => { duration, frames }
page is optional for stop and status when only one stream is active. Stream keys are secrets: status output and logs only ever show redacted destinations (rtmp://host/…).

Limitations

  • Ends with the page. The stream is tied to the Playwright page. It stops when the page closes or the session is reset or deleted.
  • One stream per page. Use repeated --rtmp to send the same page to several platforms with one encode.
  • One encode per stream. Streaming several pages at once runs one real-time ffmpeg encode each, so CPU cost adds up.

Streaming vs recording

recording.*stream.*
Outputvideo file on diskRTMP endpoints
Durationauto-stops after 15 minruns until stopped, survives CLI exit
Audiooff by defaulton by default
Encodingffmpeg, H.264 or VP8ffmpeg, H.264 with fixed keyframe interval