Skip to main content

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

Windows 10 version 1903 (May 2019 Update) or later is required for WGC support.
  • 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
If packages don’t restore automatically:
4

Build the solution

Or from the command line:
The executable will be output to:
  • Debug: x64\Debug\DisplayCaptureProject.exe
  • Release: x64\Release\DisplayCaptureProject.exe

Configuration

config.json Setup

The host reads configuration from a config.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: 2

Audio 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 config.json is in the same directory, then run:
The host will:
  1. Connect to the matchmaker and register itself
  2. Send heartbeats every 20 seconds
  3. Wait for client connections
  4. Begin capturing and streaming when a client connects

Startup Logs

You should see output similar to:

Troubleshooting

Build Errors

Solution: Install the Windows 10 SDK via Visual Studio Installer
The project requires Windows SDK 10.0.17134.0 or later.
Solution: Restore NuGet packages
Solution: The CppWinRT package is not properly installed

Runtime Errors

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
Solutions:
  • Verify the matchmaker is running
  • Check matchmaker.url in config.json
  • Verify hostSecret matches the matchmaker’s HOST_SECRET
  • Check firewall rules
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
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
Solutions:
  • Lower video.fps (try 30 instead of 60)
  • Use faster NVENC preset (p1 or p2)
  • Reduce resolution in window.targetWidth/Height
  • Enable capture.skipUnchanged: true
  • Set capture.mmcss.enable: true for thread priority boost
Solutions:
  • Use CBR rate control: video.rc: "cbr"
  • Disable B-frames: video.bf: 0
  • Use fastest preset: video.preset: "p1"
  • Reduce video.pacingFixedUs for 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

For production deployments:
  • Run the host in a dedicated user account with minimal permissions
  • Use Windows Firewall to restrict outbound connections
  • Change hostSecret to a strong random value
  • Use WSS (secure WebSocket) for signaling
  • Monitor logs for suspicious activity
  • Keep Windows and GPU drivers updated

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