locked
How to Set the Video Capture Resolution - using Media Foundation in Win7 RRS feed

  • Question

  • I am working on a application which can set the resolution of the video capture, and I am coding follow the sample MFCaptureD3D, I think the API:

    MFSetAttributeSize(pType, MF_MT_FRAME_SIZE, m_width, m_height);

    can set the frame size, but I found I cannot set the resolution successfully, is there a problem in my decoding in D3D or this API cannot set the frame size?

    Additionally, how can I set the capture display, like brightness and hue etc., not in graphic cards but in camera setting, maybe use IPropertyStore? But I don't know how to use it?

    I'm a new to Media Foundation, let me know if you have any suggestions in study it.

    Thank a lot for anyone can help me!

    HRESULT DrawDevice::SetVideoType(IMFMediaType *pType)
    {
        HRESULT hr = S_OK;
        GUID subtype = { 0 };
        MFRatio PAR = { 0 };
    
        hr = pType->GetGUID(MF_MT_SUBTYPE, &subtype);
    
        if (FAILED(hr)) { goto done; }
    
        hr = SetConversionFunction(subtype);
    
        if (FAILED(hr)) { goto done; }
    
        m_width = 800;
        m_height = 600;
        hr = MFSetAttributeSize(pType, MF_MT_FRAME_SIZE, m_width, m_height);
        if (FAILED(hr)) { goto done; }
    
    
        m_interlace = (MFVideoInterlaceMode)MFGetAttributeUINT32(
            pType,
            MF_MT_INTERLACE_MODE,
            MFVideoInterlace_Progressive	
            );
    
        // Get the image stride.
        hr = GetDefaultStride(pType, &m_lDefaultStride);
    
        if (FAILED(hr)) { goto done; }
    
        // Get the pixel aspect ratio. Default: Assume square pixels (1:1)
    
        hr = MFGetAttributeRatio(
            pType,
            MF_MT_PIXEL_ASPECT_RATIO,
            (UINT32*)&PAR.Numerator,
            (UINT32*)&PAR.Denominator
            );
    
        if (SUCCEEDED(hr))
        {
            m_PixelAR = PAR;
        }
        else
        {
            m_PixelAR.Numerator = m_PixelAR.Denominator = 1;
        }
    
        m_format = (D3DFORMAT)subtype.Data1;
    
        // Create Direct3D swap chains.
    
        hr = CreateSwapChains();
    
        if (FAILED(hr)) { goto done; }
    
    
        // Update the destination rectangle for the correct
        // aspect ratio.
    
        UpdateDestinationRect();
    
    done:
        if (FAILED(hr))
        {
            m_format = D3DFMT_UNKNOWN;
            m_convertFn = NULL;
        }
        return hr;
    }


    • Edited by Nicholas.Hu Wednesday, May 23, 2012 10:18 AM
    Wednesday, May 23, 2012 9:57 AM

All replies

  • You cannot modify the media type exposed by the source.  You can access properties by querying the media source for IKsControl and using the KS property system.  Video capture minidriver property sets might be a useful reference.  Not all capture devices support all properties.
    Monday, June 18, 2012 10:39 PM