想让一个程序先正常显示视频头捕捉到的数据,然后随时可以调用一个函数进行流保存到AVI文件!
第一步没有问题,但是第2不再次创建
pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi,   L"C:\\Example.avi",   &ppf,   &pSink);
hr=pBuilder->RenderStream(
                &PIN_CATEGORY_PREVIEW,     //   Pin   category   PIN_CATEGORY_CAPTURE
                &MEDIATYPE_Video,               //   Media   type
                pSrc,                                       //   Capture   filter
                NULL,                                       //   Compression   filter   (optional)
                NULL                                           //   Multiplexer   or   renderer   filter
        ); //这里就失败了
不知道为什么,谁能解决啊?
如果能提供类似2个功能的代码,不胜感激!

解决方案 »

  1.   

    应该有一个sample数据copy的过程,建议先做写文件成功后再整合
      

  2.   

    楼上的,能给段代码吗,?为什么我所保存的AVI播放时无法渲染呢
      

  3.   

    因为我的程序初始化里没有用SetOutputFileName()函数
    而在想保存AVI时,我从用了SetOutputFileName(),这个时候是不是一定要把以前的Graph对象销毁重新初始化啊?不懂,请指教
      

  4.   

    rageliu(长白山的水怪居然是假的 近期目标是还债!!!等有钱了去):
    请问我如何才能把第一次初始化的Graph对象销毁掉啊,要不第2次保存AVI的Graph对象初始化就失败,就想你说的只能用一个Graph对象,我的函数如下
    void CCaptureVideo::ClearGraphs()
    { // Destroy capture graph
        if( m_pGB )
        {
            // have to wait for the graphs to stop first
            //
            CComQIPtr< IMediaControl, &IID_IMediaControl > pControl = m_pGB;
            if( pControl ) 
                pControl->Stop( );        // make the window go away before we release graph
            // or we'll leak memory/resources
            // 
            CComQIPtr< IVideoWindow, &IID_IVideoWindow > pWindow = m_pGB;
            if( pWindow )
            {
                pWindow->put_Visible( OAFALSE );
                pWindow->put_Owner( NULL );
            }
    /*
    #ifdef REGISTER_FILTERGRAPH
            // Remove filter graph from the running object table   
            if (g_dwGraphRegister)
                RemoveGraphFromRot(g_dwGraphRegister);
    #endif
    */
            m_pGB->Release( );
            m_pGrabber.Release( );
        }   
    }可是好象没有完全销毁掉