NetLibDirectshowCapture 1.0.1

dotnet add package NetLibDirectshowCapture --version 1.0.1                
NuGet\Install-Package NetLibDirectshowCapture -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetLibDirectshowCapture" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetLibDirectshowCapture --version 1.0.1                
#r "nuget: NetLibDirectshowCapture, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetLibDirectshowCapture as a Cake Addin
#addin nuget:?package=NetLibDirectshowCapture&version=1.0.1

// Install NetLibDirectshowCapture as a Cake Tool
#tool nuget:?package=NetLibDirectshowCapture&version=1.0.1                

NetLibDirectshowCapture

Build NuGet

A .NET Wrapper of libdshowcapture using .NET 8.0 C++/CLI

This is a direct wrapper, so almost all behaviors should be consistent with libdshowcapture. And it should be compatible with all the devices that OBS Studio supports.

Performance

This library is written in C++/CLI (aka. C++ Interop), which has better performance according to Microsoft. All the marshaling details are manually controlled for optimized performance and latency. The callback exposed the native pointer directly, which eliminate all of the unnecessary copies. It should has lower latency compared to other camera library using explicit P/Invoke.

Usage Example

// List all capture devices
var videoDevices = NetLibDirectshowCapture.Device.EnumVideoDevices();
var videoDevice = videoDevices[0];
// Check device's capabilities
var cap = videoDevice.Capabilities
    .First(c => c.Format == VideoFormat.YUY2 && c.MaxCx == 1920 && c.MaxCy == 1080);
// Create config
VideoConfig videoConfig = new VideoConfig()
{
    Name = videoDevice.Name,
    Path = videoDevice.Path,
    UseDefaultConfig = false,
    Cx = cap.MaxCx,
    CyAbs = cap.MaxCy,
    CyFlip = false,
    FrameInterval = cap.MinInterval,
    InternalFormat = cap.Format,
    Format = VideoFormat.XRGB
};
byte[] managedArray = null;
// Create frame event handler
videoConfig.OnVideoCaptured += (o, e) =>
{
    managedArray ??= new byte[e.Length];
    System.Runtime.InteropServices.Marshal.Copy(e.Ptr, managedArray, 0, e.Length);
    // Process frames using managedArray...
};
// Run!
var device = new Device();
device.ResetGraph();
device.VideoConfiguration = videoConfig;
device.ConnectFilters();
device.Start();

Git Submodules

Since this repo contains libdshowcapture as its submodule, please use --recurse-submodules flag when cloning.

git clone --recurse-submodules git@github.com:charlescao460/NetLibDirectshowCapture.git
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 169 3/28/2024