Skip to main content

Streaming Configuration Reference

Complete reference for Hyperscape’s RTMP streaming system with WebGPU rendering.

Overview

Hyperscape’s streaming pipeline captures gameplay via Chrome DevTools Protocol (CDP) and streams to multiple platforms simultaneously (Twitch, Kick, X/Twitter). The system requires WebGPU for rendering and uses NVIDIA GPU acceleration via Vulkan.

Critical Requirements

WebGPU is REQUIRED

  • NO WebGL fallback - All shaders use TSL (Three Shading Language)
  • Chrome must have WebGPU enabled and working
  • NVIDIA GPU with Vulkan support required for server/streaming
  • Headless Chrome modes that don’t support WebGPU will NOT work

GPU Rendering Modes

The deployment script (scripts/deploy-vast.sh) tries multiple approaches in order:
  1. Xorg with NVIDIA (preferred):
    • Full hardware acceleration
    • Best performance and quality
    • Requires DRI/DRM device access
    • Config: /etc/X11/xorg-nvidia-headless.conf
  2. Xvfb with NVIDIA Vulkan (fallback):
    • Virtual framebuffer for X11 protocol
    • Chrome uses NVIDIA GPU via ANGLE/Vulkan
    • CDP captures from Chrome’s internal GPU rendering
    • Works in containers without DRM access
  3. Deployment FAILS if neither works:
    • No soft fallback to headless mode
    • WebGPU is non-negotiable

Environment Variables

GPU & Display Configuration

Chrome Configuration

Audio Configuration

RTMP Destinations

Streaming Behavior

Audio Capture Setup

PulseAudio Configuration

The deployment script sets up PulseAudio in user mode with a virtual sink:
  1. Create runtime directory:
  2. Create PulseAudio config (~/.config/pulse/default.pa):
  3. Start PulseAudio:
  4. Verify sink exists:

FFmpeg Audio Capture

FFmpeg captures from the PulseAudio monitor device:
Parameters:
  • thread_queue_size=1024 - Prevents buffer underruns
  • use_wallclock_as_timestamps=1 - Real-time timing
  • aresample=async=1000:first_pts=0 - Recovers from audio drift (22ms threshold)

FFmpeg Encoding Configuration

Video Encoding

Audio Encoding

Output Flags

Capture Modes

CDP Mode (Default)

Chrome DevTools Protocol screencast capture:
Advantages:
  • 2-3x faster than MediaRecorder
  • No browser-side encoding overhead
  • Single encode step: JPEG → H.264
  • Works in headful and headless modes
  • Hardware accelerated on supported platforms
How it works:
  1. CDP Page.startScreencast captures compositor frames
  2. Frames sent as base64 JPEG to Node.js
  3. Decoded and piped to FFmpeg stdin
  4. FFmpeg encodes to H.264 and sends to RTMP

MediaRecorder Mode (Legacy)

Browser MediaRecorder API with WebSocket:
Fallback mode - Used if CDP capture fails or stalls.

WebCodecs Mode (Experimental)

Native VideoEncoder API with stream copy:
Experimental - Falls back to CDP if no traffic within 20s.

Troubleshooting

WebGPU Not Available

Symptoms:
  • Black screen in stream
  • “WebGPU not supported” errors
  • Chrome falls back to software rendering
Solutions:
  1. Verify NVIDIA GPU is accessible: nvidia-smi
  2. Check Vulkan support: vulkaninfo --summary
  3. Verify X server is running: xdpyinfo -display :99
  4. Check Chrome WebGPU: Navigate to chrome://gpu in browser
  5. Verify VK_ICD_FILENAMES points to NVIDIA ICD

Audio Not Captured

Symptoms:
  • Stream has video but no audio
  • FFmpeg shows audio input errors
Solutions:
  1. Verify PulseAudio is running: pulseaudio --check
  2. Check chrome_audio sink exists: pactl list short sinks
  3. Verify monitor device: pactl list short sources | grep monitor
  4. Check FFmpeg can access PulseAudio: ffmpeg -f pulse -list_devices true -i dummy
  5. Verify PULSE_SERVER environment variable is set

Stream Buffering/Stuttering

Symptoms:
  • Viewers see buffering
  • Inconsistent frame rate
  • Audio/video desync
Solutions:
  1. Increase buffer size: STREAM_BUFFER_MULTIPLIER=4 (or higher)
  2. Use film tune for better compression: STREAM_LOW_LATENCY=false
  3. Check network bandwidth to RTMP servers
  4. Verify CDP FPS matches target: Check logs for “CDP FPS: X”
  5. Monitor dropped frames: Check logs for “Dropped: X”

Xorg/Xvfb Failures

Symptoms:
  • Deployment fails with “Cannot establish WebGPU-capable rendering mode”
  • Xorg falls back to swrast (software rendering)
Solutions:
  1. Verify NVIDIA drivers are installed: nvidia-smi
  2. Check DRI devices exist: ls -la /dev/dri/
  3. Review Xorg logs: cat /var/log/Xorg.99.log
  4. Verify GPU BusID is correct in xorg config
  5. Check for conflicting X servers: pkill -9 Xorg; pkill -9 Xvfb
  6. Clean up lock files: rm -f /tmp/.X99-lock

Performance Tuning

Low Latency Mode

For minimal latency (at cost of compression efficiency):

High Quality Mode

For better compression and smoother playback:

Resource Optimization

For lower CPU/memory usage:

Monitoring & Diagnostics

Health Checks

The streaming system exposes health endpoints:

Log Monitoring

Diagnostic Commands

See Also