网络摄像头 MJPG 捕获流在 Windows 10 上不可用 [英] Webcam MJPG capture streams are unavailable on Windows 10

查看:63
本文介绍了网络摄像头 MJPG 捕获流在 Windows 10 上不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

On Windows 10 build 10.1607.14393.10 (aka Anniversary edition) I am unable to get MJPG capture streams anymore. Used to be both MJPG and YUY2 resolutions, now I am getting only YUY2 in DirectShow (Kernel Streaming) and in Media Foundation MJPG converted media types into NV12 way before IBaseFilter source is connected to anything. Tried on multiple systems with different cameras. Any ideas what might be wrong?

     640x480   @30   YUY2
     ...
     640x480   @30   MJPG <- gone
 ...
DirectShow:
    com_t<IAMStreamConfig> sc;
    if_failed_return_result(camera_output_pin->QueryInterface(&sc));
    int number_of_capabilities = 0;
    int capability_size = 0;
    if_failed_return(sc->GetNumberOfCapabilities(&number_of_capabilities, &capability_size), -1);
    for (int i = 0; i < number_of_capabilities && k < count; i++) {
        VIDEO_STREAM_CONFIG_CAPS scc;
        assert(sizeof(scc) == capability_size);
        AM_MEDIA_TYPE* mt = null;
        if_failed_return(sc->GetStreamCaps(i, &mt, (BYTE*)&scc), -1);
...

In MMF:

    640x480   @30   YUY2
    ...
    640x480   @30   NV12 // camera reports MJPG 4cc in USBView and KsStudio

for (int i = 0; k < count; i++) {
    com_t<IMFMediaType> type;
    if (d->reader->GetNativeMediaType(VIDEO_STREAM, i, &type) != 0) {
        break;
    }
    GUID guid_major_type = {0};
    if_failed_return_result(type->GetMajorType(&guid_major_type));
    if (guid_major_type == MFMediaType_Video) {
        GUID guid_subtype = {0};
        if_failed_return_result(type->GetGUID(MF_MT_SUBTYPE, &guid_subtype));
        AM_MEDIA_TYPE* amMediaType = null;
        if_failed_return_result(type->GetRepresentation(FORMAT_MFVideoFormat, (void**)&amMediaType));
        assert(amMediaType->cbFormat == sizeof(MFVIDEOFORMAT));
        const MFVIDEOFORMAT* mi = (const MFVIDEOFORMAT*)amMediaType->pbFormat;

解决方案

As explained by Mike M from Microsoft,

So yes, MJPEG and H.264 being decoded / filtered out is the result of a set of features we needed to implement, and this behavior was planned, designed, tested, and flighted out to our partners and Windows Insiders around the end of January of this year. We worked with partners to make sure their applications continued to function throughout this change, but we have done a poor job communicating this change out to you guys. We dropped the ball on that front, so I’d like to offer my apologies to you all.

In Windows 10 Anniversary Update MJPG video from webcam is captured by new helper service "Windows Camera Frame Server", which is self-introducing itself as "Enables multiple clients to access video frames from camera devices.". The same is mentioned by Mike M.

I for one was unable to see multiple clients sharing a camera as second instance of TopoEdit gave me typical error: Error starting playback. Hardware MFT failed to start streaming due to lack of hardware resources.

MJPG and H264 media types however are indeed filtered out as the platform update now claims responsibility to avoid scenarios where multiple clients access the same camera simultaneously and each one does decoding on its own duplicating the effort.

One of the main reasons that Windows is decoding MJPEG for your applications is because of performance. With the Anniversary Update to Windows 10, it is now possible for multiple applications to access the camera in ways that weren’t possible before. It was important for us to enable concurrent camera access, so Windows Hello, Microsoft Hololens and other products and features could reliably assume that the camera would be available at any given time, regardless of what other applications may be accessing it. One of the reasons this led to the MJPEG decoding is because we wanted to prevent multiple applications from decoding the same stream at the same time, which would be a duplicated effort and thus an unnecessary performance hit.

Apparently this "improvement" caught many by surprise.

UPDATE. It was detected that behavior to use new Frame Server feature can be disabled system wide by creating a registry value as defined below. Once Media Foundation API sees this value it chooses an original code path to talk to "hardware" (KS proxy) directly bypassing Frame Server.

  • Key Name:
    • HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows Media FoundationPlatform (64-bit apps; 32-bit apps in 32-bit OS)
    • HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindows Media FoundationPlatform (32-bit apps in 64-bit OS)
  • Value Name: "EnableFrameServerMode" REG_DWORD
  • Value: 0

这篇关于网络摄像头 MJPG 捕获流在 Windows 10 上不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆