Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

Media Foundation: Cannot change a FPS on webcam

$
0
0

Hi All,

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.

My codes:

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->GetNativeMediaType(dwStreamIndex, 0, &pNativeType);
if (FAILED(hr))
{
  //error
}

GUID majorType, subtype;

// Find the major type.
hr = pNativeType->GetGUID(MF_MT_MAJOR_TYPE, &majorType);
if (FAILED(hr))
{
  //error
}
// Define the output type.
hr = MFCreateMediaType(&pType);
if (FAILED(hr))
{
  //error
}
hr = pType->SetGUID(MF_MT_MAJOR_TYPE, majorType);
if (FAILED(hr))
{
  //error
}
// Select a subtype.
if (majorType == MFMediaType_Video)
{
    subtype= MFVideoFormat_RGB24;
}
else
{
  //error
}
hr = pType->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->SetCurrentMediaType(dwStreamIndex, NULL, pType);
if (FAILED(hr))
{// hr = 0xc00d5212
  //!!!!!error - if fps == 25
}
return hr;

I tried to research  my webcam (Logitech HD Webcam C310) by MF utility (http://alax.info/blog/1579)  and got the followings: my webcam can work only with 1 and 30 fps. But DS GraphEdit shown me another things - 5, 10, 15, 20, 25 and 30 fps. Why?

Thanks for any help.


Viewing all articles
Browse latest Browse all 1079

Trending Articles