IMFSourceReader giving error 0x80070491 for some resolutions

2

I'm trying to catpure video from a 5MP UVC camera using an IMFSourceReader from Microsoft Media Foundation (on Windows 7 x64). Everything works just like the documentation with no errors on any API calls until the first callback into OnReadSample() which has "0x80070491 There was no match for the specified key in the index" as it's hrStatus parameter.

When I set the resolution down to 1080p it works fine even though 5MP is the camera's native resolution and 5MP (2592x1944) enumerates as an available format.

I can't find anything in the the Microsoft documentation to say that this behaviour is by design but it seems consistent so far. Has anyone else got IMFSourceReader to work at more that 1080p?

I see the same effects on the Microsoft MFCaptureToFile example when it's forced to select the native resolution:

HRESULT nativeTypeErrorCode = S_OK;
DWORD count = 0;
UINT32 streamIndex = 0;
UINT32 requiredWidth = 2592;
UINT32 requiredheight = 1944;
while ( nativeTypeErrorCode == S_OK )
{
    IMFMediaType * nativeType = NULL;
    nativeTypeErrorCode = m_pReader->GetNativeMediaType( streamIndex, count, &nativeType );
    if ( nativeTypeErrorCode != S_OK ) continue;

// get the media type 
    GUID nativeGuid = { 0 };
    hr = nativeType->GetGUID( MF_MT_SUBTYPE, &nativeGuid );

    if ( FAILED( hr ) ) return hr;

    UINT32 width, height;
    hr = ::MFGetAttributeSize( nativeType, MF_MT_FRAME_SIZE, &width, &height );

    if ( FAILED( hr ) ) return hr;

    if ( nativeGuid == MFVideoFormat_YUY2 && width == requiredWidth && height == requiredheight )
    {
        // found native config, set it
        hr = m_pReader->SetCurrentMediaType( streamIndex, NULL, nativeType );
        if ( FAILED( hr ) ) return hr;          
        break;
    }

    SafeRelease( &nativeType );
    count++;
}

Is there some undocumented maximum resolution with Media Framework?

frameworks
media
ms-media-foundation
asked on Stack Overflow Apr 1, 2014 by user3485279 • edited Apr 7, 2014 by Grhm

2 Answers

0

It turns out that the problem was with the camera I was using, NOT the media streaming framework or UVC cameras generally.

I have switched back to using DirectShow sample grabbing which seems to work ok so far.

answered on Stack Overflow Apr 7, 2014 by user3485279
0

I ran into this same problem on windows 7 with a usb camera module I got from Amazon.com (ELP-USBFHD01M-L21). The default resolution of 1920x1080x30fps (MJPEG) works fine, but when I try to select 1280x720x60fps (also MJPEG, NOT h.264) I get the 0x80070491 error in the ReadSample callback. Various other resolutions work OK, such as 640x480x120fps. 1280x720x9fps (YUY2) also works.

The camera works fine at 1280x720x60fps in Direct Show.

Unfortunately, 1280x720x60fps is the resolution I want to use to do some fairly low latency augmented reality stuff with the Oculus Rift.

Interestingly, 1280x720x60fps works fine with the MFCaptureD3D sample in Windows 10 technical preview. I tried copying the ksthunk.sys and usbvideo.sys drivers from my windows 10 installation to my windows 7 machine, but they failed to load even when I booted in "Disable Driver Signing" mode.

After looking around on the web, it seems like various people with various webcams have run into this problem. I'm going to have to use DirectShow to do my video capture, which is annoying since it is a very old API which can't be used with app store applications.

I know this is a fairly obscure problem, but since Microsoft seems to have fixed it in Windows 10 it would be great if they backported the fix it to Windows 7. As it is, I can't use their recommended media foundation API because it won't work on most of the machines I have to run it on.

In any case, if you are having this problem, and Windows 10 is an option, try that as a fix.

Max Behensky

answered on Stack Overflow Jun 22, 2015 by Max Behensky

User contributions licensed under CC BY-SA 3.0