Overview
The Windows host is a C++/Go application that:- Captures video using Windows Graphics Capture (WGC)
- Encodes video with FFmpeg hardware acceleration (NVENC/QSV/AMF)
- Captures audio via WASAPI
- Streams media over WebRTC using Pion
- Receives input from clients via WebRTC DataChannels
Requirements
System Requirements
- OS: Windows 10 (1903+) or Windows 11
- CPU: Modern multi-core processor (4+ cores recommended)
- GPU: NVIDIA (GTX 900+ series), Intel (6th gen+), or AMD with hardware encoding
- RAM: 4 GB minimum, 8+ GB recommended
- Network: Low-latency connection (5+ Mbps upload per stream)
Development Tools
- Visual Studio 2019 or 2022
- Desktop development with C++ workload
- Windows 10 SDK (10.0.17134.0 or later)
- Platform Toolset v141, v142, or v143
- Go 1.19 or later (for WebRTC stack)
- FFmpeg with hardware encoding support
Building the Host
Open the Visual Studio solution
Open
DisplayCaptureProject.sln in Visual Studio.The project supports multiple configurations:- Debug|x64: Development build with debug symbols
- Release|x64: Optimized production build
Only x64 (64-bit) builds are supported. Win32 (32-bit) is not supported.
Restore NuGet packages
Visual Studio should automatically restore the required packages:
Microsoft.Windows.CppWinRT(2.0.220531.1)- Windows 10 SDK references
Configuration
config.json Setup
The host reads configuration from aconfig.json file that must be placed in the same directory as the executable.
Key Configuration Options
Host Settings
| Field | Type | Description | Default |
|---|---|---|---|
targetProcessName | string | Name of the game/application to capture | Required |
signalingUrl | string | WebSocket URL of signaling server | Required |
matchmaker.url | string | HTTP URL of matchmaker service | Required |
matchmaker.hostSecret | string | Shared secret for host authentication | HELLO-MFS |
matchmaker.heartbeatIntervalMs | number | Heartbeat interval to matchmaker (ms) | 20000 |
Window Settings
| Field | Type | Description | Default |
|---|---|---|---|
window.resizeClientArea | boolean | Resize game window to target dimensions | true |
window.targetWidth | number | Target window width | 1920 |
window.targetHeight | number | Target window height | 1080 |
Video Encoding
| Field | Type | Description | Default |
|---|---|---|---|
video.fps | number | Target framerate | 60 |
video.bitrateStart | number | Initial bitrate (bps) | 8000000 |
video.bitrateMin | number | Minimum bitrate for ABR (bps) | 8000000 |
video.bitrateMax | number | Maximum bitrate for ABR (bps) | 12000000 |
video.preset | string | NVENC preset (p1-p7, lower=faster) | p2 |
video.rc | string | Rate control mode (cbr, vbr) | cbr |
video.bf | number | B-frames (0 for lowest latency) | 0 |
For ultra-low latency: use
preset: "p1", rc: "cbr", bf: 0For better quality at higher latency: use preset: "p4", rc: "vbr", bf: 2Audio Capture
| Field | Type | Description | Default |
|---|---|---|---|
audio.processLoopback.enabled | boolean | Capture only target process audio (Win11+) | false |
audio.bitrate | number | Opus bitrate (bps) | 80000 |
audio.enableFec | boolean | Enable forward error correction | true |
audio.complexity | number | Opus complexity (0-10) | 6 |
Input Injection
| Field | Type | Description | Default |
|---|---|---|---|
input.blockWinKeys | boolean | Block Windows key during session | true |
input.releaseAllOnDisconnect | boolean | Release all keys on disconnect | true |
input.injectionPolicy | string | REQUIRE_FOREGROUND or ALLOW_BACKGROUND | REQUIRE_FOREGROUND |
input.maxInjectHz | number | Max input rate (events/sec) | 10000 |
Running the Host
Start the game or application
Launch the target application specified in
config.json as targetProcessName.Startup Logs
You should see output similar to:Troubleshooting
Build Errors
Error: Windows SDK not found
Error: Windows SDK not found
Solution: Install the Windows 10 SDK via Visual Studio InstallerThe project requires Windows SDK 10.0.17134.0 or later.
Error: C++/WinRT package not found
Error: C++/WinRT package not found
Solution: Restore NuGet packages
Error: Cannot open include file 'winrt/...'
Error: Cannot open include file 'winrt/...'
Solution: The CppWinRT package is not properly installed
Runtime Errors
Error: Target process not found
Error: Target process not found
The host cannot find the game executable specified in
targetProcessName.Solutions:- Ensure the process name matches exactly (case-sensitive)
- Launch the game before starting the host
- Use Task Manager to verify the exact process name
- For UWP games, use the package family name
Error: Failed to connect to matchmaker
Error: Failed to connect to matchmaker
Solutions:
- Verify the matchmaker is running
- Check
matchmaker.urlin config.json - Verify
hostSecretmatches the matchmaker’sHOST_SECRET - Check firewall rules
Error: Graphics capture failed
Error: Graphics capture failed
WGC (Windows Graphics Capture) initialization failed.Solutions:
- Update Windows to version 1903 or later
- Update GPU drivers
- Enable “Graphics Capture” in Windows Settings
- Run as Administrator if capturing elevated processes
Error: Hardware encoder not available
Error: Hardware encoder not available
FFmpeg cannot initialize NVENC/QSV/AMF.Solutions:
- Update GPU drivers
- Verify GPU supports hardware encoding:
- NVIDIA: GTX 900 series or newer
- Intel: 6th gen (Skylake) or newer
- AMD: VCE 1.0 or newer
- Check GPU is not fully utilized by other applications
Performance: High CPU usage
Performance: High CPU usage
Solutions:
- Lower
video.fps(try 30 instead of 60) - Use faster NVENC preset (
p1orp2) - Reduce resolution in
window.targetWidth/Height - Enable
capture.skipUnchanged: true - Set
capture.mmcss.enable: truefor thread priority boost
Performance: High latency
Performance: High latency
Solutions:
- Use CBR rate control:
video.rc: "cbr" - Disable B-frames:
video.bf: 0 - Use fastest preset:
video.preset: "p1" - Reduce
video.pacingFixedUsfor faster frame pacing - Enable
audio.latency.strictLatencyMode: true
Production Deployment
Running as a Windows Service
For production, run the host as a Windows service using NSSM or similar:Security Hardening
Monitoring
Key metrics to monitor:- CPU usage: Should be under 50% for good performance
- GPU usage: Encoder should be under 80%
- Network upload: Matches configured bitrate
- Frame drops: Should be near zero
- Matchmaker heartbeats: Should succeed every 20 seconds
Next Steps
- Signaling Server Deployment - Set up the WebRTC signaling infrastructure
- Matchmaker Deployment - Configure host registration service
- Client Deployment - Deploy the browser client