DirectShow fails with black frames and 0x80070005 on Win7/Win10

1

I'm developing a small video capture library on top of videoInput (a thin wrapper around DirectShow) and lately I encountered a tricky issue.

The library captures and saves video frames to its internal format, using code to the effect of this:

if (VI->setupDevice(m_deviceIndex, width, height)) {
  //... checks for frame size etc
  //...
  auto pixels = VI->getPixels(m_deviceIndex, true, true);
}

This code was built in VS 2017 using vc140/sdk8.1 and it worked fine on a range of different machines running Windows 7, 8.1 and 10, which included typical office desktops and laptops, several development machines, a highly restrictive production desktop and VirtualBox guests.

Then we discovered that on one Windows 7 computer videoInput yields black frames (null pixels), even though the camera itself works properly with other applications. We tested several different camera models to the same effect.

I built DirectShow examples from official Microsoft repository and discovered that on startup the samples fail with hr=0x80070005 error (access denied), regardless of running in elevated mode. Here's where the error occurs (amcap.cpp, line 787).

Since official samples supposedly should work out of the box, I suspected that there might be a compatibility bug in later versions of SDK/MSVC and tried compiling with VS 2010, but that didn't help. I also tried different capture back-ends, using Windows Media Foundation example from the same repository, as well as OpenCV with ffmpeg - all to the same effect.

Then we discovered another machine, running Windows 10, which had exactly the same problem, indicating that this is not an issue of backwards compatibility. Meanwhile, the same builds were working fine on my test machines, and third-party applications like Webcamoid were working fine on the problematic PCs.

My best guess is that there's some kind of compatibility flag or permission which has to be granted, since the camera works just fine with third-party software, but I have no idea where to look for them, and Windows 7 doesn't have camera permission settings to begin with, if I'm not mistaken.

Now, does anyone have any idea what on Earth might be wrong? I would greatly appreciate any advice.

Thank's.

c++
camera
video-capture
directshow
ms-media-foundation

1 Answer

1

Problem solved.

The problem turned out to be due to Kaspersky Endpoint Security, which has an option to restrict video streaming for unknown applications. This is why camera apps from the Store worked fine (they were trusted by default), and our application didn't.

Caveat emptor.

answered on Stack Overflow Jul 9, 2018 by Eugene Magdalits

User contributions licensed under CC BY-SA 3.0