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
1
Clone the repository
2
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.
3
Restore NuGet packages
Visual Studio should automatically restore the required packages:
Microsoft.Windows.CppWinRT(2.0.220531.1)- Windows 10 SDK references
4
Build the solution
- Debug:
x64\Debug\DisplayCaptureProject.exe - Release:
x64\Release\DisplayCaptureProject.exe
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
Window Settings
Video Encoding
For ultra-low latency: use
preset: "p1", rc: "cbr", bf: 0For better quality at higher latency: use preset: "p4", rc: "vbr", bf: 2Audio Capture
Input Injection
Running the Host
1
Start the game or application
Launch the target application specified in
config.json as targetProcessName.2
Run the host executable
Ensure The host will:
config.json is in the same directory, then run:- Connect to the matchmaker and register itself
- Send heartbeats every 20 seconds
- Wait for client connections
- Begin capturing and streaming when a client connects
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