開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
vs6 vs2008
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
directshow
問題(Question):
從camera 讀取畫面後轉成 AVI 寫入
實測試無法把影像存成AVI 程式會自動結束
如何同時把聲音寫入?
程式碼(Code):(請善用置底文網頁, 記得排版)
hr = pGraph->AddFilter(pCap,L"Vid Capture Filter");
IBaseFilter *pMux = 0;
hr =
pBuild->SetOutputFileName(&MEDIASUBTYPE_Avi,L"c:\\video.avi",&pMux,NULL);
if( FAILED(hr) )
{
printf("ERROR - SetOutputFileName () failed \n");
return ;
}
hr =
pBuild->RenderStream(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,pCap,NULL,pMux);
if( FAILED(hr) )
{
printf("ERROR - RenderStream () failed \n");
return ;
}
IConfigAviMux *pConfigMux = NULL;
hr = pMux->QueryInterface(IID_IConfigAviMux, (void**)&pConfigMux );
if(SUCCEEDED(hr))
{
pConfigMux->Release();
}
//設定輸出camera 畫面
hr = pBuild->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pCap,
NULL, NULL);
if(FAILED(hr))
{
printf("ERROR - RenderStream() failed.\n");
return;
}
printf("SUCCESS - RenderStream() succeeded.\n");
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.133.28.13
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1430112878.A.B2A.html
※ 編輯: liang168 (220.133.28.13), 04/27/2015 13:37:07
※ 編輯: liang168 (220.133.28.13), 04/27/2015 13:37:54
※ 編輯: liang168 (220.133.28.13), 04/27/2015 13:52:32