How to set frame rate in webcam using direct show
-
Samstag, 3. März 2012 13:15
Hi,
I am using direct show for getting stream from webcam connected to my system.
My camera supports 2048*1536 resolution at 12.5 fps.
All I want is to change the streaming frame rate from 12.5 to 5 to fulfilling some desired behavior.
Can any one help me out to achieve this using direct show code?
Any help will be appreciated.
Thanks in advance,
Sanket Mehta
Alle Antworten
-
Samstag, 3. März 2012 19:43Sanket Mehta wrote:>>I am using direct show for getting stream from webcam connected to my system.>>My camera supports 2048*1536 resolution at 12.5 fps.>>All I want is to change the streaming frame rate from 12.5 to 5 to>fulfilling some desired behavior.Note that your camera is not required to support arbitrary frame rates. Youcan ASK for this, but you might not get it.>Can any one help me out to achieve this using direct show code?You do it the same way that you change the frame size. Here I use theICaptureGraphBuilder2 to fetch the capture pin from the capture filter. Ifyou already have the IPin, you can ask it for the IAMStreamConfig directly.CComPtr<IAMStreamConfig> pisc;m_CapGraph->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,m_CaptureFilter,IID_IAMStreamConfig,(void**)pisc);AM_MEDIA_TYPE* pmt;pisc->GetFormat( &pmt );VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;// Set new frame rate.vih->AvgTimePerFrame = 10000000 / 5; // 5 frames per secondpisc->SetFormat( pisc );DeleteMediaType(pmt);pisc.Release();--Tim Roberts, timr@probo.comProvidenza & Boekelheide, Inc.
Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.

