charlescao460/NetLibDirectshowCapture

How to retrieve all the available VideoConfig of a device?

Closed this issue · 2 comments

When I am running the default code to connect to my camera I get System.InvalidOperationException: 'Cannot set videoConfig.'

I managed to figure it out using capabilities

    // retrieve all supported format from device
    var capabilities = device.Capabilities;
    // filter valid capabilities and create a list of VideoConfig
    var configs = capabilities.Where(cp => cp.MaxCy > 0 && cp.MaxCx > 0).Select(c => new VideoConfig()
    {
        Name = device.Name,
        Path = device.Path,
        UseDefaultConfig = false,
        Cx = c.MaxCx,
        CyAbs = c.MaxCy,
        CyFlip = false,
        FrameInterval = c.MaxInterval,
    }).ToList();

Yes, device.Capabilities is the way you get a list of all available configs