none
Setting the video capture frame rate

    Question

  •  

    Hello, I'm wondering how I can set the frame rate for the capturing video device I'm using (webcam)

     

    I've read that this needs to be done setting the format type via IAMStreamConfig however I'm unable to query this interface on the filter

     

    I'm enumerating the device via

    CLSID_VideoInputDeviceCategory

     

    Once I've added it to my graph I attempt to query IAMStreamConfig via:

     

    IAMStreamConfig *m_streamcfg;

     

    hr = pFilter->QueryInterface(IID_IAMStreamConfig, (void **)&m_streamcfg);

     

    however hr returns E_NOINTERFACE

    Sunday, December 07, 2008 10:37 PM

Answers

  •  Matthew Newcombe wrote:

    Yeah I've tried using the CComPtr stuff and include atlbase.h before but gets errors along the lines of:

     

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(365) : error

     

    ...

     

    and a couple of these

     

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h(2775) : error C2065: 'CLSID_StdGlobalInterfaceTable' : undeclared identifier

     

    ...

     

    Never figured out how to solve them.

     

    Looks like the find interface should do the job, will go check it out ty.

     

     

    The reason you are getting these errors is that you are including the Visual Studio versions of the header files rather than the Microsoft SDK versions.  In other words, the order that the VS includes appear in your project before the MS SDK ones.  This will lead to problems since the MS SDK ones are the most compatible with the target Windows versions supported by the SDK.

     

    The FindInterface is useful because the interfaces are defined on the output pins of a capture filter rather than the filter itself.  This is so that different pins can offer different settings and the parameters on each pin can be set independently of the others.

    Monday, December 08, 2008 12:08 AM
    Moderator

All replies

  • I think you use the bad way!  If pFilter is your webcam filter! Because in this case you should tell what pin you wanna queryinterface

    Try to use:
    CComPtr<IBaseFilter> pCap; // it´s my webcam
    CComPtr<ICaptureGraphBuilder2>pCaptureGraph2; // without ATL it´s ICaptureGraphBuilder * pCaptureGraph2
    [...]
        CComQIPtr<IAMStreamConfig> pPropStream; //for the interface
            hr = pCaptureGraph2->FindInterface(&PIN_CATEGORY_CAPTURE,
                                              &MEDIATYPE_Video, pCap,
                                              IID_IAMStreamConfig, (void **)&pPropStream);

    In the Amcap sample they doing it at line 2937 in amcap.cpp.


    Sunday, December 07, 2008 10:50 PM
  • You can do it with the webcam driver dialog too.
    You can call the setting dialog this way:

    CComPtr <IAMStreamConfig> pConfig;
    CComPtr <ISpecifyPropertyPages> pSpec;

    HRESULT hr = pCaptureGraph2->FindInterface(&PIN_CATEGORY_CAPTURE,
                                          &MEDIATYPE_Video, pCap,
                                          IID_IAMStreamConfig, (void **)&pConfig);
    hr = pConfig->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpec);
    if (SUCCEEDED(hr))
    {
        // Get the filter's name and IUnknown pointer.
        FILTER_INFO FilterInfo;
        hr = pCap->QueryFilterInfo(&FilterInfo);
        //IUnknown *pFilterUnk;
        //pCap->QueryInterface(IID_IUnknown, (void **)&pFilterUnk);

        // Show the page.
        CAUUID caGUID;
         hr = pSpec->GetPages(&caGUID);
        //pSpec->Release();
        OleCreatePropertyFrame(
            m_hWnd,                   // Parent window
            0, 0,                   // Reserved
            FilterInfo.achName,     // Caption for the dialog box
            1,                      // Number of objects (just the filter)
           (IUnknown**) &pConfig/*pSpec*//*pFilterUnk*/,            // Array of object pointers.
            caGUID.cElems,          // Number of property pages
            caGUID.pElems,          // Array of property page CLSIDs
            0,                      // Locale identifier
            0, NULL                 // Reserved
        );
    Sunday, December 07, 2008 10:55 PM
  • Yeah I've tried using the CComPtr stuff and include atlbase.h before but gets errors along the lines of:

     

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(365) : error C2065: 'GUID_NULL' : undeclared identifier

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(371) : error C2065: 'GUID_NULL' : undeclared identifier

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(387) : error C2065: 'GUID_NULL' : undeclared identifier

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(415) : error C2065: 'GUID_NULL' : undeclared identifier

     

    and a couple of these

     

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h(2775) : error C2065: 'CLSID_StdGlobalInterfaceTable' : undeclared identifier

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h(2946) : error C2065: 'CLSID_StdGlobalInterfaceTable' : undeclared identifier

     

    Never figured out how to solve them.

     

    Looks like the find interface should do the job, will go check it out ty.

     

     

     

    Sunday, December 07, 2008 11:13 PM
  •  Matthew Newcombe wrote:

    Yeah I've tried using the CComPtr stuff and include atlbase.h before but gets errors along the lines of:

     

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlcomcli.h(365) : error

     

    ...

     

    and a couple of these

     

    1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h(2775) : error C2065: 'CLSID_StdGlobalInterfaceTable' : undeclared identifier

     

    ...

     

    Never figured out how to solve them.

     

    Looks like the find interface should do the job, will go check it out ty.

     

     

    The reason you are getting these errors is that you are including the Visual Studio versions of the header files rather than the Microsoft SDK versions.  In other words, the order that the VS includes appear in your project before the MS SDK ones.  This will lead to problems since the MS SDK ones are the most compatible with the target Windows versions supported by the SDK.

     

    The FindInterface is useful because the interfaces are defined on the output pins of a capture filter rather than the filter itself.  This is so that different pins can offer different settings and the parameters on each pin can be set independently of the others.

    Monday, December 08, 2008 12:08 AM
    Moderator
  • Yeah I tried that putting the dx headers above in visualstudio options vc directories but it didn't solve the issue (http://forums.microsoft.com/msdn/showpost.aspx?postid=4067890&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1)

    Monday, December 08, 2008 12:21 AM
  • then try without atl...
    should be the last of your problems now...
    Monday, December 08, 2008 3:55 AM
  • btw. atl works not with vc++ express edition...
    Monday, December 08, 2008 3:18 PM
  • See https://msdn.microsoft.com/en-us/library/windows/desktop/dd375791(v=vs.85).aspx for useful functions for finding the interface. Then you call the following on your graph:

     IAMStreamConfig *pConfig = NULL; hr = FindInterfaceAnywhere(graph, IID_IAMStreamConfig, (void**)&pConfig);

    HRESULT FindPinInterface(
    	IBaseFilter *pFilter,  // Pointer to the filter to search.
    	REFGUID iid,           // IID of the interface.
    	void **ppUnk)          // Receives the interface pointer.
    {
    	if (!pFilter || !ppUnk) return E_POINTER;
    
    	HRESULT hr = E_FAIL;
    	IEnumPins *pEnum = 0;
    	if (FAILED(pFilter->EnumPins(&pEnum)))
    	{
    		return E_FAIL;
    	}
    	// Query every pin for the interface.
    	IPin *pPin = 0;
    	while (S_OK == pEnum->Next(1, &pPin, 0))
    	{
    		hr = pPin->QueryInterface(iid, ppUnk);
    		pPin->Release();
    		if (SUCCEEDED(hr))
    		{
    			break;
    		}
    	}
    	pEnum->Release();
    	return hr;
    }
    
    HRESULT FindInterfaceAnywhere(
    	IGraphBuilder *pGraph,
    	REFGUID iid,
    	void **ppUnk)
    {
    	if (!pGraph || !ppUnk) return E_POINTER;
    	HRESULT hr = E_FAIL;
    	IEnumFilters *pEnum = 0;
    	if (FAILED(pGraph->EnumFilters(&pEnum)))
    	{
    		return E_FAIL;
    	}
    	// Loop through every filter in the graph.
    	IBaseFilter *pF = 0;
    	while (S_OK == pEnum->Next(1, &pF, 0))
    	{
    		hr = pF->QueryInterface(iid, ppUnk);
    		if (FAILED(hr))
    		{
    			// The filter does not expose the interface, but maybe
    			// one of its pins does.
    			hr = FindPinInterface(pF, iid, ppUnk);
    		}
    		pF->Release();
    		if (SUCCEEDED(hr))
    		{
    			break;
    		}
    	}
    	pEnum->Release();
    	return hr;
    }
    

    • Edited by Darthmallow Wednesday, April 19, 2017 8:56 AM
    Wednesday, April 19, 2017 8:54 AM