IEnumPins *pEnumPins;
pCap->EnumPins(&pEnumPins);
IPin *pPin;
PIN_DIRECTION PinDir;
while(pEnumPins->Next(1, &pPin, 0)==S_OK) {
        pPin->QueryDirection(&PinDir);
        if(PinDir == PINDIR_OUTPUT) {
                CComQIPtr pAMSC (pPin);
                
                int iCount, iSize;
                VIDEO_STREAM_CONFIG_CAPS scc;
                AM_MEDIA_TYPE *pmt;

                pAMSC->GetNumberOfCapabilities(&iCount, &iSize);
                
                if(sizeof(scc) != iSize)
                {
                        // This is not the structure we were expecting.
                        return E_FAIL;
                }
                // Get the first format.
                hr = pAMSC->GetStreamCaps(0, &pmt, reinterpret_cast(&scc));
                if(hr == S_OK)
                {
                        pmt->subtype = MEDIASUBTYPE_RGB24;
                        VIDEOINFOHEADER *vih = reinterpret_cast(pmt->pbFormat);
                        vih->bmiHeader.biWidth = 640;
                        vih->bmiHeader.biHeight = 480;
                        vih->bmiHeader.biSizeImage = 640*480*3;
                        pmt->lSampleSize = 640*480*3;
                        pAMSC->SetFormat(pmt);
                }

                break;
        }
}