Hi guys, i wonder how to make my programm work in mode without debugging(Ctrl+F5). When i start my programm that captures video and audio to asf file from web-cam in debug (F5) it works good i can see a video in small window and everything is good. But when i start it in Ctrl+F5 it still writes a video and audio to file, but i can't see a preview video in small window (the window is getting wite and not responding) Please help me to find the problem
My programm code:
int main(int argc, char* argv[])
{
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
ICaptureGraphBuilder2 *pCaptureGraph = NULL; IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; IFileSinkFilter *pSink = NULL; IBaseFilter *pAudioInputFilter = NULL; IBaseFilter *pVideoInputFilter = NULL; IBaseFilter *pASFWriter = NULL;
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return hr;
}
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void **)&pCaptureGraph);
if (FAILED(hr)) {
printf("ERROR - Could not create the Filter Graph Manager.");
return hr;
}
hr = pCaptureGraph->SetOutputFileName(&MEDIASUBTYPE_Asf,
L"C:\\MyWebcam.ASF", &pASFWriter, &pSink);
hr = ShowFilterPropertyPages(pASFWriter);
hr = pCaptureGraph->GetFiltergraph(&pGraph);
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
if (FAILED(hr))
{
printf("ERROR - Could not create the Media Control object.");
pGraph->Release(); CoUninitialize(); return hr;
}
hr = EnumerateAudioInputFilters((void**) &pAudioInputFilter);
hr = EnumerateAudioInputPins(pAudioInputFilter);
hr = pGraph->AddFilter(pAudioInputFilter, L"Audio");
hr = GetVideoInputFilter(&pVideoInputFilter, L"HP Webcam");
if (SUCCEEDED(hr)) {
hr = pGraph->AddFilter(pVideoInputFilter, L"Video");
}
IBaseFilter *pIntermediate = NULL;
hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
pVideoInputFilter, NULL, NULL);
hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
pVideoInputFilter, NULL, pASFWriter);
hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio,
pAudioInputFilter, NULL, pASFWriter);
if (SUCCEEDED(hr))
{
hr = pControl->Run();
if (SUCCEEDED(hr))
{
wprintf(L"Started recording...press Enter to stop recording.\n");
boost::chrono::duration<double> sec = boost::chrono::system_clock::now() - start;
std::cout << "took " << sec.count() << " seconds\n";
char ch;
ch = getchar();
}
hr = pControl->Stop();
wprintf(L"Stopped recording.\n");
SaveGraphFile(pGraph, L"C:\\MyGraph.GRF");
}
pSink->Release();
pASFWriter->Release();
pVideoInputFilter->Release();
pAudioInputFilter->Release();
pControl->Release();
pGraph->Release();
pCaptureGraph->Release();
CoUninitialize();
return 0;
}
This is my video screen picture :
http://imageupload.org/en/file/202245/witescreen.jpg.html[