Hi Could someone help me out on this problem. I have been stuck on this for ages and couldnt find anything to solve it.
The following is my unfinished code I am using to capture video.
**************************************************
CODE
#include "stdio.h"
#include "dshow.h"
#include "strmif.h"
void main()
{
//******INITIALIZE**********************************
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
// Add error-handling code here. (Omitted for clarity.)
}
//**************************************************
//************CREAT FILTER GRAPH MANAGER***********************
IGraphBuilder *pGraph;
hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
//**********************************************************
//IMediaControl controls streaming.
//It contains methods for stopping and starting the graph.
IMediaControl *pControl;
//IMediaEvent has methods for getting events from the Filter Graph Manager.
//In this example, the interface is used to wait for playback to complete.
IMediaEvent *pEvent;
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
//*****BUILD FILTER GRAPH**********************
//hr = pGraph->RenderFile(L"C:\\A.avi", NULL);
//*********************************************
//IGraphBuilder *pGraph = NULL;
ICaptureGraphBuilder2 *pBuild = NULL;
// Create the Capture Graph Builder.
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pGraph);
// Initialize the Capture Graph Builder.
hr=pBuild->SetFiltergraph(pGraph);
//************RUN**************************
hr = pControl->Run();
//****************************************
//***************HOLD TILL FINISH VIDEO********************
long evCode = 0;
pEvent->WaitForCompletion(INFINITE, &evCode);
//*********************************************************
//****RELEASE INTERFACE POINTERS AND CLOSE COM LIBRARY*******
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
//***********************************************************
}
********************************************************
The code builds fine, but when I run it, it crashes out without telling me what errors there are.
I tested out each line of the code and it seems to crash out (terminates prematurely when I initialize the capture graph builder:
hr=pBuild->SetFiltergraph(pGraph);Any help on this would be greatly greatly greatly appreciated,
Thank you for any little help in advance!!!
cchan
This post has been edited by Dark_Nexus: 1 Oct, 2006 - 02:17 PM