您的位置:首页 > 其它

如何修改Asf Writer中的profile,以达到改变输出屏幕大小?

2006-09-12 11:51 411 查看
贴上最近的源代码:(注意一下里面的PIN值)
ConfigAsfWriter (CComQIPtr<IWMProfile> profile,int width,int height,int nQuality)
{
HRESULT hr;
// CComQIPtr<IConfigAsfWriter> pConfig = m_pAsfWriter;
DWORD dwBitrate = nQuality;//m_myConfig.nQuality;//nQuality//92160;//921600;
CComQIPtr<IWMProfile> pProfile = profile;

//删除多余的其它流数据,否则会出错
DWORD nStreamCount;
hr = pProfile->GetStreamCount(&nStreamCount);
ASSERT (nStreamCount <= 2); //最多只能有两个接口,否则不是期望的profile
ERROR_BOX2(hr);
if (nStreamCount > 1)
{
hr = pProfile->RemoveStreamByNumber(1);
ERROR_BOX2(hr);
}

CComQIPtr<IWMStreamConfig> pStreamConfig;
hr = pProfile->GetStream(0, &pStreamConfig); //因为应该只有一个流,所以获取视频流的
ERROR_BOX2(hr);

/////设置视频流的属性
//CComQIPtr<IWMMediaProps> pMediaProps;
CComQIPtr<IWMVideoMediaProps> pMediaProps;
pMediaProps = pStreamConfig;
ASSERT (!!pMediaProps);

hr = pStreamConfig->SetBitrate(dwBitrate);
ERROR_BOX2(hr);

//WM_MEDIA_TYPE *pType = reinterpret_cast<WM_MEDIA_TYPE *>( &mt );
WM_MEDIA_TYPE *mediaType;
DWORD bufsize;
pMediaProps->GetMediaType(NULL,&bufsize);
BYTE *pBuf = new BYTE[bufsize];
mediaType = (WM_MEDIA_TYPE*) pBuf;
pMediaProps->GetMediaType(mediaType,&bufsize);

VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(mediaType->pbFormat);
//VIDEOINFOHEADER *pVih2 = reinterpret_cast<VIDEOINFOHEADER*>(pType->pbFormat);

//memcpy (pVih,pVih2,sizeof(VIDEOINFOHEADER));
pVih->bmiHeader.biWidth = width;//m_myConfig.videoWidth;//pVih2->bmiHeader.biWidth;
pVih->bmiHeader.biHeight = height;//m_myConfig.videoHeight;//pVih2->bmiHeader.biHeight;
pVih->bmiHeader.biSizeImage = GetBitmapSize(&pVih->bmiHeader);//pVih2->bmiHeader.biSizeImage;
mediaType->bFixedSizeSamples = 1;
mediaType->lSampleSize = pVih->bmiHeader.biSizeImage;
RECT src = {0,0,pVih->bmiHeader.biWidth,pVih->bmiHeader.biHeight};
pVih->rcSource = src;
pVih->rcTarget = src;
pVih->dwBitRate = dwBitrate;

hr = pMediaProps->SetMediaType (mediaType);
ERROR_BOX2(hr);

hr = pProfile->ReconfigStream (pStreamConfig);
ERROR_BOX2(hr);

// hr = pConfig->ConfigureFilterUsingProfile(pProfile);
// ERROR_BOX2(hr);
delete []pBuf;

// m_pProfile = pProfile;
return hr;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: