Video Capture SDK for C# .NET — Webcam, Screen, and IP Camera Capture API¶
Introduction¶
The Video Capture SDK for .NET is a C# video capture API that lets you record from webcams, IP cameras (RTSP/ONVIF), and screens in your .NET applications. It replaces low-level DirectShow video capture code with a modern async API — enumerate devices, configure sources, and start recording in a few lines of C#.
The SDK handles device enumeration, format negotiation, GPU-accelerated encoding, and file output across Windows, macOS, and Linux. Whether you need to save an RTSP stream to file, capture photos from a webcam, or build a screen capture tool, the API covers it.
Quick Start¶
1. Install NuGet Packages¶
dotnet add package VisioForge.DotNet.VideoCapture
Add platform-specific native dependencies:
<!-- Windows x64 -->
<PackageReference Include="VisioForge.CrossPlatform.Core.Windows.x64" Version="2025.11.0" />
<PackageReference Include="VisioForge.CrossPlatform.Libav.Windows.x64" Version="2025.11.0" />
<!-- macOS -->
<PackageReference Include="VisioForge.CrossPlatform.Core.macOS" Version="2025.9.1" />
<!-- Linux x64 -->
<PackageReference Include="VisioForge.CrossPlatform.Core.Linux.x64" Version="2025.11.0" />
<PackageReference Include="VisioForge.CrossPlatform.Libav.Linux.x64" Version="2025.11.0" />
For the full list of packages and UI framework support (WinForms, WPF, MAUI, Avalonia), see the Installation Guide.
2. Initialize the SDK¶
Call InitSDKAsync() once at application startup before using any capture functionality:
using VisioForge.Core;
await VisioForgeX.InitSDKAsync();
3. C# Webcam Capture to MP4 (Minimal Example)¶
using VisioForge.Core;
using VisioForge.Core.VideoCaptureX;
using VisioForge.Core.Types.X.Sources;
using VisioForge.Core.Types.X.Output;
// Create capture instance linked to a VideoView control
var capture = new VideoCaptureCoreX(videoView);
// Enumerate available devices
var videoDevices = await DeviceEnumerator.Shared.VideoSourcesAsync();
var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync();
// Configure video and audio sources
capture.Video_Source = new VideoCaptureDeviceSourceSettings(videoDevices[0]);
capture.Audio_Source = audioDevices[0].CreateSourceSettingsVC();
capture.Audio_Record = true;
// Add MP4 output (H.264 + AAC, GPU-accelerated when available)
capture.Outputs_Add(new MP4Output("recording.mp4"));
// Start capture
await capture.StartAsync();
// ... when done:
await capture.StopAsync();
await capture.DisposeAsync();
4. Cleanup at Shutdown¶
VisioForgeX.DestroySDK();
Core Workflow¶
Every capture application follows the same pattern:
- Initialize SDK —
VisioForgeX.InitSDKAsync()(once per app lifetime) - Enumerate devices —
DeviceEnumerator.Shared.VideoSourcesAsync()/AudioSourcesAsync() - Create capture object —
new VideoCaptureCoreX(videoView)for preview, or without a view for headless recording - Configure source — Set
Video_Sourceto a webcam, IP camera, screen, or other source - Configure output — Add one or more outputs:
MP4Output,WebMOutput,AVIOutput, etc. - Start —
await capture.StartAsync() - Stop —
await capture.StopAsync()finalizes the output file - Dispose —
await capture.DisposeAsync()releases all resources
Common C# Video Capture Scenarios¶
Record Webcam Video in C¶
Record from a USB webcam or built-in camera to MP4 with H.264/AAC:
capture.Video_Source = new VideoCaptureDeviceSourceSettings(device);
capture.Outputs_Add(new MP4Output("webcam.mp4"));
See the full tutorial: Save Webcam Video in C#
Save RTSP Stream to File in C¶
Connect to IP cameras and save RTSP streams to MP4 files. Supports RTSP, ONVIF, and HTTP protocols:
capture.Video_Source = new RTSPSourceSettings(
new Uri("rtsp://192.168.1.100:554/stream"))
{
Login = "admin",
Password = "password"
};
capture.Outputs_Add(new MP4Output("ipcam.mp4"));
See: IP Camera to MP4 | RTSP Guide | ONVIF Guide
C# Screen Capture to MP4¶
Record the desktop or a specific screen region to MP4:
capture.Video_Source = new ScreenCaptureSourceSettings()
{
FrameRate = new VideoFrameRate(30),
CaptureCursor = true
};
capture.Outputs_Add(new MP4Output("screen.mp4"));
Audio-Only Recording¶
Record from a microphone without video:
capture.Audio_Source = audioDevices[0].CreateSourceSettingsVC();
capture.Audio_Record = true;
capture.Video_Record = false;
capture.Outputs_Add(new MP4Output("audio.mp4"));
Capture Photo from Webcam¶
Grab a still image from the live webcam video feed:
capture.Snapshot_Grabber_Enabled = true;
await capture.StartAsync();
// Later, save a frame:
await capture.Snapshot_SaveAsync("photo.jpg", SKEncodedImageFormat.Jpeg, 85);
See: Webcam Photo Capture
Supported Input Devices¶
Cameras and Capture Hardware¶
- USB webcams and capture devices (up to 4K)
- DV and HDV MPEG-2 camcorders
- Professional PCI capture cards
- Television tuners (with and without MPEG encoder)
Network and IP Cameras¶
- RTSP-enabled IP cameras
- JPEG/MJPEG HTTP cameras
- RTMP streaming sources
- ONVIF-compatible cameras
- SRT and NDI sources
Browse our IP camera brands directory for brand-specific RTSP URLs and connection guides covering 60+ manufacturers.
Professional and Industrial Equipment¶
- Blackmagic Decklink capture devices
- Microsoft Kinect and Kinect 2
- GenICam / GigE Vision / USB3 Vision industrial cameras
Audio Sources¶
- System audio capture devices and sound cards
- Professional ASIO audio devices
- Audio loopback (system sound) capture
Output Formats and Encoders¶
The SDK supports multiple output containers and codecs. GPU-accelerated encoding (NVIDIA NVENC, AMD AMF, Intel Quick Sync) is used automatically when available.
| Format | Video Codecs | Audio Codecs | Use Case |
|---|---|---|---|
| MP4 | H.264, H.265 (HEVC) | AAC | General purpose, widest compatibility |
| WebM | VP8, VP9, AV1 | Vorbis, Opus | Web delivery, royalty-free |
| AVI | MJPEG, custom codecs | PCM, MP3 | Legacy compatibility |
| MKV | H.264, H.265, VP9 | AAC, Vorbis, FLAC | Flexible container, multiple tracks |
| GIF | Animated GIF | — | Short clips, previews |
For detailed codec configuration, see Output Formats and Video Encoders.
Platform Support¶
| Platform | UI Frameworks | Notes |
|---|---|---|
| Windows x64 | WinForms, WPF, MAUI, Avalonia, Console | Full feature set including DirectShow sources |
| macOS | MAUI, Avalonia, Console | AVFoundation camera access |
| Linux x64 | Avalonia, Console | V4L2 camera access |
| Android | MAUI | Via MAUI camera integration |
| iOS | MAUI | Via MAUI camera integration |
Migrating from DirectShow Video Capture¶
If you're currently using DirectShow (DirectShow.NET) for video capture in C#, the Video Capture SDK provides a modern replacement. Instead of manually building filter graphs with IGraphBuilder, connecting pins, and managing COM objects, you use typed settings classes and async methods.
| DirectShow Concept | Video Capture SDK Equivalent |
|---|---|
IGraphBuilder filter graph | Managed automatically by VideoCaptureCoreX |
ICaptureGraphBuilder2 | Not needed — source and output configured via properties |
Device enumeration via DsDevice | DeviceEnumerator.Shared.VideoSourcesAsync() |
ISampleGrabber for frame access | Snapshot_SaveAsync() or OnVideoFrameBuffer event |
| Manual pin connection | Automatic — or use Media Blocks SDK for explicit pipelines |
COM cleanup / Marshal.ReleaseComObject | Standard IAsyncDisposable pattern |
For a detailed migration guide with side-by-side code examples, see Migrate from DirectShow.NET.
Developer Documentation¶
Core Functionality¶
Advanced Features¶
- Video Capture Implementation
- Audio Capture Implementation
- Motion Detection
- Network Streaming
- Pre-Event Recording
- Synchronizing Multiple Captures
Tutorials (Step-by-Step with Code)¶
- Webcam to MP4 | to AVI | to WMV
- Screen Capture to MP4 | to AVI | to WMV
- IP Camera Preview | IP Camera to MP4
- Text Overlay on Webcam
- Camera Video Preview
- All Video Tutorials
Guides¶
- Save Webcam Video in C#
- Record Webcam in VB.NET
- Screen Capture in VB.NET
- Webcam Photo Capture
- All Guides