当前位置: 代码迷 >> 多媒体/流媒体开发 >> 关于怎么将摄像头输入转换为已录制好的AVI视频输入
  详细解决方案

关于怎么将摄像头输入转换为已录制好的AVI视频输入

热度:2995   发布时间:2013-02-26 00:00:00.0
关于如何将摄像头输入转换为已录制好的AVI视频输入
求各位大侠帮我看看 小妹初学 研究多日而不得法 急求解决之道   感激不尽!!!!

我将原来的摄像头捕获滤波器改为m_pGraph-> AddSourceFilter(L "***.avi ",L "Source   Filter ",   &m_pFileSource)又添加了   m_pGraph-> AddFilter(m_pAviSplit,   L "AVI   Splitter ")但是调试时总在连接那段报错 
原代码如下:
void   CCDAppDoc::ConnectGraph()
{
HRESULT   hr;

//   get   output   "capture "   pin   from   the   device.     We   use   the   capture   pin
//   since   not   all   devices   have   a   preview   pin.
IPin   *pCapOut   =   GetOutPin(m_pSrc,   0);


        我将上面这行改为   IPin   *pFileOut   =GetOutPin(m_pFileSource,   0)
下面几行未做改动,


//   query   the   capture   output   pin   to   get   the   stream   config   filter
pCapOut-> QueryInterface(IID_IAMStreamConfig,(void**)&m_pStreamConfig);

//   create   a   media   type   to   hold   the   pin   media   type
AM_MEDIA_TYPE   *MediaType   =   new   AM_MEDIA_TYPE();

//   get   the   current   media   type
m_pStreamConfig-> GetFormat(&MediaType);


编译可以通过,只是在调试时总在上面这行出错,按步调试发现m_pStreamConfig返回值为0x00000000,但是原来从摄像头输入时m_pStreamConfig并不为空,不知道如何改进

//   get   the   video   info   for   this   pin
VIDEOINFOHEADER   *pvi   =   (VIDEOINFOHEADER   *)MediaType-> pbFormat;

//If   video   size   is   larger   than   320x240
if(pvi-> bmiHeader.biWidth   >   320)
{
//   change   the   size   of   the   video   to   320   x   240
pvi-> bmiHeader.biHeight   =   240;
pvi-> bmiHeader.biWidth   =   320;
}

//Get   the   final   video   dimensions
m_VideoWidth   =   pvi-> bmiHeader.biWidth;
m_VideoHeight   =   pvi-> bmiHeader.biHeight;

//Re-size   the   window   to   fit   the   input   video
int   win_width   =   (2*pvi-> bmiHeader.biWidth   +   20);
int   win_height   =   (pvi-> bmiHeader.biHeight   +   80);
AfxGetApp()-> m_pMainWnd-> SetWindowPos(NULL,0,0,win_width,win_height,NULL);

//   set   the   media   type   with   these   changes
MediaType-> pbFormat   =   (unsigned   char*)pvi;

//   set   the   format
m_pStreamConfig-> SetFormat(MediaType);

//   get   the   input   pin   from   the   infinite   tee   filter
IPin   *pInfiniteIn   =   GetInPin(m_pInfiniteTeeFilter,0);

hr   =   m_pGraph-> Connect(pCapOut,pInfiniteIn);


上面两行改为IPin   *pAviSplitIn   =   GetInPin(m_pAviSplit,0);
            hr   =   m_pGraph-> Connect(pFileOut,pAviSplitIn);
          IPin   *pAviSplitOut   =GetOutPin(m_pAviSplit,   0);
IPin   *pInfiniteIn   =   GetInPin(m_pInfiniteTeeFilter,0);
              hr   =   m_pGraph-> Connect(pAviSplitOut,pInfiniteIn);


其余代码未做改动


//   get   the   first   output   pin   from   the   infinite   tee   filter
  相关解决方案