I'm writing an USB camera-capture program using DirectShow. I've succeeded previewing and writing the captured stream to an AVI file. But the written file is very slow because it isn't compressed. I don't know how to add a compression filter into the capture graph. Please show me any code about capture program.
Kim Sung Gyoo
Posts
-
USB camera capture code!! (DirectShow) -
DirectShow problem..(compression filter)I'm writing an USB camera-capture program using DirectShow. I've succeeded previewing and writing the captured stream to an AVI file. But the written file is very slow because it isn't compressed. I don't know how to add a compression filter into the capture graph. So I've added some code fragment about compression filter, but it didn't work. How can I work with a compression filter?? Here's my code fragment. // File-Writing section - capture // Capture Filter Graph ICaptureGraphBuilder2 *m_pBuilder = NULL; // Filter Graph IGraphBuilder *m_pGraph = NULL; // Capture Filter IBaseFilter *m_pSrc = NULL; // AVI MUX Filter IBaseFilter *m_ppf = NULL; // File Writer IFileSinkFilter *m_pSink = NULL; // AVI Compression Filter (doesn't work!!) IBaseFilter *m_pComp = NULL; // omitted...... m_pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi, L"C:\\Example.avi", &m_ppf, &m_pSink); // Creating a compression filter CoCreateInstance (CLSID_AVICo, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void **)&m_pComp); m_pGraph->AddFilter (m_pComp, L"Compressor"); m_pBuilder->RenderStream (&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pSrc, m_pComp, // compression filter. m_ppf // Default renderer. ); // Rendering the streams - preview m_pBuilder->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, m_pSrc, NULL, // No compression filter. NULL // Default renderer. ); :confused:
-
DirectShow problem..(compression filter)I'm writing an USB camera-capture program using DirectShow. I've succeeded previewing and writing the captured stream to an AVI file. But the written file is very slow because it isn't compressed. I don't know how to add a compression filter into the capture graph. So I've added some code fragment about compression filter, but it didn't work. How can I work with a compression filter?? Here's my code fragment. // File-Writing section - capture // Capture Filter Graph ICaptureGraphBuilder2 *m_pBuilder = NULL; // Filter Graph IGraphBuilder *m_pGraph = NULL; // Capture Filter IBaseFilter *m_pSrc = NULL; // AVI MUX Filter IBaseFilter *m_ppf = NULL; // File Writer IFileSinkFilter *m_pSink = NULL; // AVI Compression Filter (doesn't work!!) IBaseFilter *m_pComp = NULL; // omitted...... m_pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi, L"C:\\Example.avi", &m_ppf, &m_pSink); // Creating a compression filter CoCreateInstance (CLSID_AVICo, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void **)&m_pComp); m_pGraph->AddFilter (m_pComp, L"Compressor"); m_pBuilder->RenderStream (&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pSrc, m_pComp, // compression filter. m_ppf // Default renderer. ); // Rendering the streams - preview m_pBuilder->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, m_pSrc, NULL, // No compression filter. NULL // Default renderer. );