IEnumPins *pEnumPins;
pFilterMP3Encoder->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;
                AUDIO_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<byte*>(&scc));
                if (hr == S_OK)
                {
                        if (pmt->formattype == FORMAT_WaveFormatEx && 
                                pmt->subtype == FORMAT_DYNA_MPEG3)
                        {
                                // Modify the format block.
                                WAVEFORMATEX *wave = 
                                        reinterpret_cast<waveformatex*>(pmt->pbFormat);
                                wave->nSamplesPerSec = 22050;
                                // Now set the format.
                                hr = pAMSC->SetFormat(pmt);
                                if (FAILED(hr))
                                {
                                        AfxMessageBox("SetFormat Failed");
                                }
                                DeleteMediaType(pmt);
                        }
                }
                break;
        }
}