Error on RenderStream in Direcshow Capture
-
Tuesday, May 15, 2012 12:25 PM
I am making an Directshow Application to Capture MP4 video. I use below graph to do so.
i create the require filters and connect them on graph , at end i do file writer operation and redder stream using pin as capture. that part of my code is as below.
GUID guid;
guid = MEDIASUBTYPE_x264;
hr = gcap.pBuilder->SetOutputFileName(&guid, gcap.wszCaptureFile,
&g_mp4mux, &gcap.pSink);
hr = gcap.pBuilder->RenderStream(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved,
gcap.pVCap, pVcompFilter, NULL);
if(hr != NOERROR)
{
hr = gcap.pBuilder->RenderStream(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
gcap.pVCap, pVcompFilter, NULL);
if(hr != NOERROR)
{
ErrMsg(TEXT("Cannot render video capture stream"));
TearDownGraph();
return FALSE;
}
}On above code
g_mp4muxisGDCL MPEG-4 MuliplexrerfilerPVcompFilterisx264vfw H.264/MPEG-4 AVC codecFilterwhen i run above code i get HR =
E_INVALIDARG.no idea what is wrong in above code. Plz help. Thanks.
- Edited by Meghana Ravani Tuesday, May 15, 2012 12:26 PM
All Replies
-
Wednesday, May 16, 2012 5:22 AMMeghana Ravani wrote:>>I am making an Directshow Application to Capture MP4 video. I use below>graph to do so.>>>i create the require filters and connect them on graph , at end i do>file writer operation and redder stream using pin as capture. that>part of my code is as below.>>GUID guid;>guid = MEDIASUBTYPE_x264;>>hr = gcap.pBuilder->SetOutputFileName(&guid, gcap.wszCaptureFile,> &g_mp4mux, &gcap.pSink);>...>g_mp4mux is GDCL MPEG-4 Muliplexrer filerThat won't work. Did you read the documentation for SetOutputFileName? Ifyou specify a mediasubtype, it must be either MEDIASUBTYPE_Avi orMEDIASUBTYPE_Asf. The graph doesn't know how to handle MEDIASUBTYPE_x264.What you should do here is pass the CLSID for the GDCL MPEG4 mux filter.SetOutputFileName will then create the mux and return it to you ing_mp4Mux.--Tim Roberts, timr@probo.comProvidenza & Boekelheide, Inc.
Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc. -
Wednesday, May 16, 2012 7:15 AM
Hi, @Tim Roberts.. Thanks for your reply.
I also tried by setting media subtype to MEDIASUBTYPE_Avi , it is giving me HRESULT = 'E_INVALIDARG' .
i came to know from your post that SetOutputFileName should return me the mux filter , but where i should pass the CLSID of it , so it return me the GDLC Mux filter which i need. i am new to directshow and vc++ code so forgive me if i asked stupid question .
I insert my code block for creating GDLC mux filter as below.and then pass it to SetOutputFileName method .
// Create instance of mp4mux IBaseFilter *g_mp4mux=NULL; hr = CoCreateInstance(CLSID_GDCLMp4Mux, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, ( void **) &g_mp4mux); if (FAILED(hr)){ ErrMsg(TEXT("Cannot create MJpeg Decommpression Filter")); return FALSE; } // add mp4mux to graph gcap.pFg->AddFilter(g_mp4mux, L"Mux Filter");
- Edited by Meghana Ravani Wednesday, May 16, 2012 7:16 AM
- Edited by Meghana Ravani Wednesday, May 16, 2012 7:20 AM
- Edited by Meghana Ravani Wednesday, May 16, 2012 7:27 AM
-
Friday, May 18, 2012 3:26 AMMeghana Ravani wrote:>>i came to know from your post that SetOutputFileName should return me the mux>filter , but where i should pass the CLSID of it , so it return me the GDLC>Mux filter which i need.Did you read the documentation at all? The description of the pTypeparameter says what you need to know. You EITHER provide the GUID of themedia type you want, or the CLSID of the mux you want.>I insert my code block for creating GDLC mux filter as below.and then pass it to SetOutputFileName method .>// Create instance of mp4mux> IBaseFilter *g_mp4mux=NULL;> hr = CoCreateInstance(CLSID_GDCLMp4Mux, NULL, CLSCTX_INPROC_SERVER,> IID_IBaseFilter, ( void **) &g_mp4mux);>...> // add mp4mux to graph> gcap.pFg->AddFilter(g_mp4mux, L"Mux Filter");Nope, skip ALL of that.ICaptureGraphBuilder2* pcgb;...pcgb->SetOutputFileName(CLSID_GDCLMp4Mux, L"name.mp4", &g_mp4mux, NULL);--Tim Roberts, timr@probo.comProvidenza & Boekelheide, Inc.
Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.


