Media Foundation: Cannot change a FPS on webcam
<p>I try to replace codes  with Directshow ("DS") on Media Foundation ("MF") in my app and met one problem - cannot set a needed fps using MF on a webcam. MF allowed me to set only 30 fps. If I try to set 25 fps, I always get the error 0xc00d5212 on SetCurrentMediaType().  In DS I could change that parameter.</p>

<p>My codes:</p>

<pre><code>ASSERT(m_pReader); //IMFSourceReader *m_pReader;
IMFMediaType *pNativeType = NULL;
IMFMediaType *pType = NULL;
UINT32 w = 1280; 
UINT32 h = 720; 
UINT32 fps = 25; // or 30

DWORD dwStreamIndex = MF_SOURCE_READER_FIRST_VIDEO_STREAM;

// Find the native format of the stream.
HRESULT hr = m_pReader-&gt;GetNativeMediaType(dwStreamIndex, 0, &amp;pNativeType);
if (FAILED(hr))
{
  //error
}

GUID majorType, subtype;

// Find the major type.
hr = pNativeType-&gt;GetGUID(MF_MT_MAJOR_TYPE, &amp;majorType);
if (FAILED(hr))
{
  //error
}
// Define the output type.
hr = MFCreateMediaType(&amp;pType);
if (FAILED(hr))
{
  //error
}
hr = pType-&gt;SetGUID(MF_MT_MAJOR_TYPE, majorType);
if (FAILED(hr))
{
  //error
}
// Select a subtype.
if (majorType == MFMediaType_Video)
{
    subtype= MFVideoFormat_RGB24;
}
else
{
  //error
}
hr = pType-&gt;SetGUID(MF_MT_SUBTYPE, subtype);
if (FAILED(hr))
{
  //error
}
hr = MFSetAttributeSize(pType, MF_MT_FRAME_SIZE, w, h);
if (FAILED(hr))
{
  //error
}
hr = MFSetAttributeSize(pType, MF_MT_FRAME_RATE, fps, 1);
if (FAILED(hr))
{
  //error
}
hr = m_pReader-&gt;SetCurrentMediaType(dwStreamIndex, NULL, pType);
if (FAILED(hr))
{// hr = 0xc00d5212 
  //!!!!!error - if fps == 25 
}
return hr;
</code></pre>

<p>Thanks for any help.</p>