Skip to content

A C# wrapper of OBSproject/libdshowcapture using .NET 5.0 with C++/CLI to utilize DirectShow on Windows

License

Notifications You must be signed in to change notification settings

yjulm/NetLibDirectshowCapture

This branch is 3 commits ahead of, 17 commits behind charlescao460/NetLibDirectshowCapture:main.

Repository files navigation

NetLibDirectshowCapture

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

This is a direct wrapper, so almost all behaviors should be consistent with libdshowcapture.

Git Submodules

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

git clone --recurse-submodules [email protected]:charlescao460/NetLibDirectshowCapture.git

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 = 1920,
    CyAbs = 1080,
    CyFlip = false,
    FrameInterval = 166666,
    InternalFormat = VideoFormat.YUY2,
    Format = VideoFormat.XRGB,
};
// Create frame event handler
videoConfig.OnVideoCaptured += (o, e) =>
{
    // Process frames using e.Array
};
// Run!
var device = new Device();
device.ResetGraph();
device.VideoConfiguration = videoConfig;
device.ConnectFilters();
device.Start();

About

A C# wrapper of OBSproject/libdshowcapture using .NET 5.0 with C++/CLI to utilize DirectShow on Windows

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 79.6%
  • C# 19.1%
  • C 1.3%