45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:修改Asf Writer中的profile以达到改变屏幕大小的步骤

修改Asf Writer中的profile以达到改变屏幕大小的步骤

2016-08-25 13:13:14 来源:www.45fan.com 【

修改Asf Writer中的profile以达到改变屏幕大小的步骤

贴上最近的源代码:(注意一下里面的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;
}


本文地址:http://www.45fan.com/a/question/67452.html
Tags: 修改 Asf Writer
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部