Overview
This guide covers performance optimization across video encoding, audio processing, capture pipeline, and network configuration. All settings reference actual configuration fromconfig.json.
Video Encoding Optimization
Bitrate Configuration
Balance quality and latency with bitrate settings:| Resolution | Min Bitrate | Recommended | Max Bitrate | Notes |
|---|---|---|---|---|
| 1080p@60fps | 6 Mbps | 8-10 Mbps | 12 Mbps | Default config |
| 1080p@120fps | 10 Mbps | 12-15 Mbps | 20 Mbps | High motion |
| 1440p@60fps | 10 Mbps | 12-16 Mbps | 20 Mbps | Higher resolution |
| 4K@60fps | 20 Mbps | 25-35 Mbps | 50 Mbps | Requires tier expansion |
- Excellent (< 20ms, < 1% loss): Use
bitrateMax - Good (20-50ms, 1-2% loss): Use
bitrateStart - Fair (50-100ms, 2-5% loss): Reduce to
bitrateMin - Poor (>100ms, >5% loss): Consider reducing
bitrateMin
Encoder Presets
NVENC preset affects encoding speed and quality:- p1 - Fastest, lowest quality, ~1-2ms encoding latency
- p2 - Fast, good quality, ~2-3ms latency (default)
- p3 - Balanced, better quality, ~3-5ms latency
- p4 - High quality, ~5-8ms latency
- p5-p7 - Highest quality, 10-20ms+ latency (not recommended for streaming)
- cbr (Constant Bitrate) - Predictable bandwidth, best for streaming
- vbr (Variable Bitrate) - Better quality, less predictable
- vbr_hq - Highest quality, highest latency
Advanced Encoder Settings
Bitrate Adaptation
Automatic bitrate adjustment based on network conditions:- Increase
cleanSamplesRequiredto 5-10 for more stable bitrate - Increase
decreaseCooldownMsto 2000-3000ms to prevent oscillation - Reduce
increaseStepBpsto 500000 (500 Kbps) for gradual ramp-up
Frame Rate Pacing
- 30fps:
pacingFixedUs: 33333 - 60fps:
pacingFixedUs: 16666(default) - 90fps:
pacingFixedUs: 11111 - 120fps:
pacingFixedUs: 8333 - 144fps:
pacingFixedUs: 6944
Audio Latency Optimization
Frame Size and Buffering
Smaller frame sizes reduce latency but increase CPU overhead:| Frame Size | Latency | CPU Usage | Packet Rate |
|---|---|---|---|
| 5ms | ~5ms | Very High | 200 pkt/s |
| 10ms | ~10ms | High | 100 pkt/s (default) |
| 20ms | ~20ms | Medium | 50 pkt/s |
| 40ms | ~40ms | Low | 25 pkt/s |
Ultra-Low Latency Mode
Audio Bitrate Adaptation
WASAPI Configuration
- ✅ Pros: 2-3ms lower latency, more consistent timing
- ❌ Cons: Blocks other applications from audio device
Capture Performance
MMCSS Priority
Multimedia Class Scheduler Service ensures consistent timing:- 1-2: Background capture
- 3-4: Normal streaming (recommended)
- 5-6: High priority for demanding games
- 7: Critical priority (may starve other processes)
Frame Pool and Queue Depth
Skip Unchanged Frames
Adaptive Backoff
adaptiveBackoff: true if capture frequently reports DXGI_ERROR_WAIT_TIMEOUT.
Network Optimization
TURN Server Placement
For clients behind restrictive NAT/firewalls: Environment Variables:- Deploy TURN servers in same region as hosts
- Use multiple TURN servers for redundancy
- Monitor TURN bandwidth usage (relay is expensive)
- Set
expirySecondsto match average session length (default: 3600s)
ICE Configuration
WebRTC connection establishment:- Host - Direct connection (lowest latency)
- Server Reflexive - Via STUN (low latency)
- Relay - Via TURN (higher latency, always works)
Buffer Pool Optimization
- 128-512B: Audio frames, small RTP packets
- 1500B: Standard MTU size
- 4KB-32KB: 1080p video frames
- 64KB-256KB: 4K low-motion frames
- 512KB-1MB: 4K high-motion frames
Input Processing Optimization
Adaptive Quality Control
Thread Priority
THREAD_PRIORITY_TIME_CRITICAL for lowest input latency.
Garbage Collection Tuning
Performance Monitoring
Track these metrics to validate tuning: Video:- Glass-to-glass latency < 50ms
- Encoder latency < 5ms
- Frame drops < 1%
- Bitrate stability (±10% variance)
- One-way latency < 40ms
- Packet loss < 2%
- No buffer underruns
- Queue depth < 2.0 average
- Frame time consistency (low jitter)
- GPU copy time < 1ms
- Queue never reaches maxQueueDepth
- RTT < 50ms
- Jitter < 5ms
- ICE connection via host/srflx (not relay)
Next Steps
- Monitoring - Track performance metrics
- Troubleshooting - Fix performance issues