Click here to Skip to main content
15,886,857 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Little advice of CFront Pin
Richard MacCutchan18-Mar-12 22:31
mveRichard MacCutchan18-Mar-12 22:31 
GeneralRe: Little advice of CFront Pin
Brandon-X1200020-Mar-12 10:09
Brandon-X1200020-Mar-12 10:09 
AnswerRe: Little advice of CFront Pin
markkuk18-Mar-12 0:08
markkuk18-Mar-12 0:08 
GeneralRe: Little advice of CFront Pin
Brandon-X1200018-Mar-12 6:45
Brandon-X1200018-Mar-12 6:45 
QuestionClassic console development kits in C, samples (Nintendo, Sega, Atari, Neo Geo, etc.)) Pin
smccd17-Mar-12 5:37
smccd17-Mar-12 5:37 
AnswerRe: Classic console development kits in C, samples (Nintendo, Sega, Atari, Neo Geo, etc.)) Pin
jschell17-Mar-12 7:50
jschell17-Mar-12 7:50 
AnswerRe: Classic console development kits in C, samples (Nintendo, Sega, Atari, Neo Geo, etc.)) Pin
Albert Holguin18-Mar-12 17:32
professionalAlbert Holguin18-Mar-12 17:32 
Questionweb-camera capture wite screen problem Pin
Member 873763117-Mar-12 5:35
Member 873763117-Mar-12 5:35 
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:

C++
int main(int argc, char* argv[])
{
	
	boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();	
    ICaptureGraphBuilder2 *pCaptureGraph = NULL;	// Capture graph builder object
	IGraphBuilder *pGraph = NULL;	// Graph builder object
    IMediaControl *pControl = NULL;	// Media control object
	IFileSinkFilter *pSink = NULL;	// File sink object
	IBaseFilter *pAudioInputFilter = NULL; // Audio Capture filter
	IBaseFilter *pVideoInputFilter = NULL; // Video Capture filter
	IBaseFilter *pASFWriter = NULL;	// WM ASF File config interface

    // Initialize the COM library.
    HRESULT hr = CoInitialize(NULL);
    if (FAILED(hr))
    {
	     // We’ll send our error messages to the console.
        printf("ERROR - Could not initialize COM library");
        return hr;
    }

    // Create the filter graph manager and query for interfaces.
    hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER,
                          IID_ICaptureGraphBuilder2, (void **)&pCaptureGraph);
    if (FAILED(hr))	// FAILED is a macro that tests the return value
    {
        printf("ERROR - Could not create the Filter Graph Manager.");
        return hr;
    }

	// Use a method of the capture graph builder
	// To create an output path for the stream 
	hr = pCaptureGraph->SetOutputFileName(&MEDIASUBTYPE_Asf, 
		L"C:\\MyWebcam.ASF", &pASFWriter, &pSink);

	// Now configure the ASF Writer
	// Present the property pages for this filter
	hr = ShowFilterPropertyPages(pASFWriter);

	// Now get the filter graph manager
	// That's part of the capture graph builder
	hr = pCaptureGraph->GetFiltergraph(&pGraph);

	 // Using QueryInterface on the graph builder, 
    // Get the Media Control object.
    hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
    if (FAILED(hr))
    {
        printf("ERROR - Could not create the Media Control object.");
        pGraph->Release();	// Clean up after ourselves.
		CoUninitialize();  // And uninitalize COM
        return hr;
    }

	
	
	// Now create the video input filter from the webcam
	hr = EnumerateAudioInputFilters((void**) &pAudioInputFilter);
	hr = EnumerateAudioInputPins(pAudioInputFilter);
	// Add the audio capture filter to the filter graph. 
	hr = pGraph->AddFilter(pAudioInputFilter, L"Audio");

	hr = GetVideoInputFilter(&pVideoInputFilter, L"HP Webcam");
	if (SUCCEEDED(hr)) {
		hr = pGraph->AddFilter(pVideoInputFilter, L"Video");
	}

	// Add a video renderer
	//IBaseFilter *pVideoRenderer = NULL;
	//hr = AddFilterByCLSID(pGraph, CLSID_VideoRenderer, L"Video Renderer", &pVideoRenderer);

	// Use another method of the capture graph builder
	// To provide a render path for video preview
	

	
	IBaseFilter *pIntermediate = NULL;
	
	
	hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
		pVideoInputFilter, NULL, NULL);
	
	// Now add the video capture to the output file
	hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
		pVideoInputFilter, NULL, pASFWriter);
	
	
	// And do the same for the audio
	hr = pCaptureGraph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio,
		pAudioInputFilter, NULL, pASFWriter);

    if (SUCCEEDED(hr))
    {
        // Run the graph.
        hr = pControl->Run();
        if (SUCCEEDED(hr))
        {
			// Wait patiently for completion of the recording
			wprintf(L"Started recording...press Enter to stop recording.\n");
			// Wait for completion.
			boost::chrono::duration<double> sec = boost::chrono::system_clock::now() - start;
			std::cout << "took " << sec.count() << " seconds\n";
			char ch;
			ch = getchar();		// We wait for keyboard input
			
        }
		
		// And let's stop the filter graph
		hr = pControl->Stop();

		wprintf(L"Stopped recording.\n");	// To the console

		// Before we finish up, save the filter graph to a file.
		SaveGraphFile(pGraph, L"C:\\MyGraph.GRF");
    }
	
	// Now release everything, and clean up.
	pSink->Release();
	pASFWriter->Release();
	pVideoInputFilter->Release();
	pAudioInputFilter->Release();
    pControl->Release();
    pGraph->Release();
	pCaptureGraph->Release();
    CoUninitialize();

	return 0;
}

Questionprime calculator Pin
Hassan Samee17-Mar-12 2:55
Hassan Samee17-Mar-12 2:55 
SuggestionRe: prime calculator Pin
Richard MacCutchan17-Mar-12 4:30
mveRichard MacCutchan17-Mar-12 4:30 
Questionvisual c++ 6 code convert to visual stutio 2010 professional Pin
bowen yang16-Mar-12 20:17
bowen yang16-Mar-12 20:17 
AnswerRe: visual c++ 6 code convert to visual stutio 2010 professional Pin
Richard MacCutchan16-Mar-12 22:23
mveRichard MacCutchan16-Mar-12 22:23 
QuestionNeed help to port example in VS6 Pin
RomTibi16-Mar-12 6:12
RomTibi16-Mar-12 6:12 
AnswerRe: Need help to port example in VS6 Pin
Jochen Arndt16-Mar-12 6:45
professionalJochen Arndt16-Mar-12 6:45 
GeneralRe: Need help to port example in VS6 Pin
RomTibi16-Mar-12 7:30
RomTibi16-Mar-12 7:30 
QuestionHow to add event handler to call another Dialog Pin
doanhanam16-Mar-12 4:30
doanhanam16-Mar-12 4:30 
AnswerRe: How to add event handler to call another Dialog Pin
Richard MacCutchan16-Mar-12 7:00
mveRichard MacCutchan16-Mar-12 7:00 
GeneralRe: How to add event handler to call another Dialog Pin
doanhanam18-Mar-12 0:10
doanhanam18-Mar-12 0:10 
GeneralRe: How to add event handler to call another Dialog Pin
Richard MacCutchan18-Mar-12 2:22
mveRichard MacCutchan18-Mar-12 2:22 
AnswerRe: How to add event handler to call another Dialog Pin
Albert Holguin16-Mar-12 18:19
professionalAlbert Holguin16-Mar-12 18:19 
QuestionMicrosoft authenticode certificate Pin
john563215-Mar-12 22:53
john563215-Mar-12 22:53 
AnswerRe: Microsoft authenticode certificate Pin
Code-o-mat16-Mar-12 0:24
Code-o-mat16-Mar-12 0:24 
QuestionDriver Installation Issue Pin
rupeshkp72815-Mar-12 21:42
rupeshkp72815-Mar-12 21:42 
AnswerRe: Driver Installation Issue Pin
Erudite_Eric15-Mar-12 21:50
Erudite_Eric15-Mar-12 21:50 
GeneralRe: Driver Installation Issue Pin
rupeshkp72815-Mar-12 21:57
rupeshkp72815-Mar-12 21:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.