Skip to main content

Streaming Improvements (February 2026)

This document describes the comprehensive streaming improvements made to Hyperscape’s RTMP broadcasting system in February 2026.

Overview

Hyperscape’s streaming system has been significantly enhanced with better buffering, audio capture, multi-platform support, and improved stability. These changes address viewer-side buffering issues, audio dropouts, and stream reliability.

Major Changes

1. Audio Capture via PulseAudio

What Changed: Streams now include game audio (music and sound effects) instead of silent audio. Implementation:
  • PulseAudio virtual sink (chrome_audio) captures browser audio
  • FFmpeg reads from monitor device (chrome_audio.monitor)
  • Async resampling prevents audio drift
  • Graceful fallback to silent audio if PulseAudio unavailable
Configuration:
See: docs/streaming-audio-capture.md for full setup guide.

2. Improved RTMP Buffering

Problem: Viewers experienced frequent buffering and stalling. Solution: Changed encoding settings for smoother playback:

Encoding Tune Change

Before: zerolatency tune (minimal buffering, unstable bitrate) After: film tune (B-frames enabled, better compression, smoother bitrate)
Restore old behavior:

Buffer Size Increase

Before: 2x bitrate (9000k buffer for 4500k bitrate) After: 4x bitrate (18000k buffer for 4500k bitrate)
Impact: More headroom during network hiccups, reduces buffering events.

Input Buffering

Added thread queue size for frame queueing:
Impact: Prevents frame drops during CPU spikes.

FLV Flags

Added FLV-specific flags for RTMP stability:
Impact: Prevents FLV header issues that could cause stream interruptions.

3. Audio Stability Improvements

Problem: Intermittent audio dropouts during video buffering. Solutions:

Wall Clock Timestamps

Maintains accurate audio timing using system clock instead of stream timestamps.

Async Resampling

Recovers from audio drift when it exceeds 22ms (1000 samples at 44.1kHz).

Removed -shortest Flag

Before: -shortest flag caused audio to stop when video buffered After: Flag removed, both streams continue independently Impact: Audio no longer drops out during temporary video buffering.

4. Multi-Platform Streaming

What Changed: Default streaming destinations updated.

Removed

  • YouTube - Explicitly disabled (set YOUTUBE_STREAM_KEY="")

Active Platforms

  • Twitch - Primary platform (lower latency)
  • Kick - Uses RTMPS with IVS endpoint
  • X (Twitter) - RTMP streaming
Configuration:
Kick URL Fix: Corrected from rtmp://ingest.kick.com to proper IVS endpoint.

5. Canonical Platform Change

Before: YouTube (15s default delay) After: Twitch (12s default delay, configurable to 0ms)
Impact: Lower latency for live betting and viewer interaction.

6. Stream Key Management

Problem: Stale stream keys in environment overrode correct values. Solution: Explicit unset and re-export in deployment script:
Impact: Correct stream keys always used, no more stale key issues.

Configuration Reference

Complete FFmpeg Command

Environment Variables

Performance Impact

Before vs After

Resource Usage

Monitoring

Stream Health

Check stream status:

FFmpeg Logs

Monitor FFmpeg output:

Audio Verification

Check audio is being captured:

Troubleshooting

No Audio in Stream

  1. Check PulseAudio:
  2. Check FFmpeg input:
  3. Test audio capture:

Buffering Issues

  1. Check bitrate:
  2. Increase buffer:
  3. Check network:

Stream Disconnects

  1. Check RTMP URL:
  2. Check stream key:
  3. Check FFmpeg errors:

Migration Guide

From Silent Audio to PulseAudio

  1. Install PulseAudio (Vast.ai deployment script does this automatically):
  2. Configure environment:
  3. Restart streaming:

From zerolatency to film Tune

No migration required. The change is automatic. To restore old behavior:

From YouTube to Twitch Canonical

No migration required. The change is automatic. Impact:
  • Default public delay: 15s → 12s
  • Can be overridden with STREAMING_PUBLIC_DELAY_MS=0

Best Practices

Production Streaming

  1. Use film tune for better compression and smoother playback
  2. Enable audio capture for better viewer experience
  3. Set public delay to 0 for live betting
  4. Monitor stream health via API and logs
  5. Use Twitch as canonical for lower latency

Development Testing

  1. Use local nginx-rtmp for testing:
  2. Test with ffplay:
  3. Monitor with ffprobe:

Quality vs Latency Tradeoff

References