// !!! What if changing output formats couldn't reconnect // and the graph is broken? Shouldn't be possible...
if (m_CaptureStuff.pVSC) { AM_MEDIA_TYPE *pmt; // get format being used NOW hr = m_CaptureStuff.pVSC->GetFormat(&pmt); // DV capture does not use a VIDEOINFOHEADER if (hr == NOERROR) { if (pmt->formattype == FORMAT_VideoInfo) { // resize our window to the new capture size ResizeWindow(HEADER(pmt->pbFormat)->biWidth, abs(HEADER(pmt->pbFormat)->biHeight)); } DeleteMediaType(pmt); } } CoTaskMemFree(cauuid.pElems); pSpec->Release(); } pSC->Release(); return TRUE; }
to: kankan98407(看看) 我是用的VFW来实现的,用BOOL capDlgVideoFormat( hwnd ); 但是显示出来的对话框只有以下三种可以选择:RGB24、IYUV、JPGL。其中哪种是YUV4:1:1的呢?我试过了,IYUV的字节数倒是跟这种格式的一样,可是我怎么都不能用…… 另外,你给的程序是怎么设置格式为严格的YUV4:1:1的?我不明白,因为我从来没有用过Directshow的,希望老兄多指点,先谢过了! 刚才发现,按照计算,抓出来的文件应该的38016的整数倍,但是却不是。
就像RGB,三原色,由红绿蓝组成一样。如果你用VFW写的,可以用 BOOL capDlgVideoFormat(
hwnd
);来设置采集格式如果用DirectshowBOOL CaptureWnd::SetVideoFmt()
{
CString strMsg;
if(!m_bHasFormatSet)
{
strMsg.LoadString(IDS_NO_SUPPORT);
return FALSE;
}
HRESULT hr = S_OK;
IAMStreamConfig *pSC;
hr = m_CaptureStuff.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved, m_CaptureStuff.pVCap,
IID_IAMStreamConfig, (void **)&pSC);
if (hr != NOERROR)
hr = m_CaptureStuff.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, m_CaptureStuff.pVCap,
IID_IAMStreamConfig, (void **)&pSC);
ISpecifyPropertyPages *pSpec;
CAUUID cauuid;
hr = pSC->QueryInterface(IID_ISpecifyPropertyPages,
(void **)&pSpec);
if (hr == S_OK)
{
hr = pSpec->GetPages(&cauuid);
hr = OleCreatePropertyFrame(m_pParentWnd->GetSafeHwnd(), 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL);
// !!! What if changing output formats couldn't reconnect
// and the graph is broken? Shouldn't be possible...
if (m_CaptureStuff.pVSC)
{
AM_MEDIA_TYPE *pmt;
// get format being used NOW
hr = m_CaptureStuff.pVSC->GetFormat(&pmt);
// DV capture does not use a VIDEOINFOHEADER
if (hr == NOERROR) {
if (pmt->formattype == FORMAT_VideoInfo)
{
// resize our window to the new capture size
ResizeWindow(HEADER(pmt->pbFormat)->biWidth,
abs(HEADER(pmt->pbFormat)->biHeight));
}
DeleteMediaType(pmt);
}
}
CoTaskMemFree(cauuid.pElems);
pSpec->Release();
}
pSC->Release(); return TRUE;
}
我是用的VFW来实现的,用BOOL capDlgVideoFormat(
hwnd
);
但是显示出来的对话框只有以下三种可以选择:RGB24、IYUV、JPGL。其中哪种是YUV4:1:1的呢?我试过了,IYUV的字节数倒是跟这种格式的一样,可是我怎么都不能用……
另外,你给的程序是怎么设置格式为严格的YUV4:1:1的?我不明白,因为我从来没有用过Directshow的,希望老兄多指点,先谢过了!
刚才发现,按照计算,抓出来的文件应该的38016的整数倍,但是却不是。
是用VFW做的,实际上是因为内存管理问题造成的,IYUV和YUV4:1:1是一样的。