Tuesday, May 29, 2007 11:55 AMHi everybody.
For a webcam preview and capture application, I am trying to set in I420 the video stream coming from my webcam.
I tried to use this code (given in directshow help) but i can't manage to initialize the config pointer pConfig. While debbuging, I saw that there the HRESULT hr is equal to E_NOINTERFACE. Have i forgotten something?
Thanks in advance.
IAMStreamConfig *pConfig = NULL;
HRESULT hr = g_pCapture->FindInterface(
&PIN_CATEGORY_PREVIEW, // Preview pin.
0, // Any media type.
pCap, // Pointer to the capture filter.
int iCount = 0, iSize = 0;
hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize);
// Check the size to make sure we pass in the correct structure.
if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
// Use the video capabilities structure.
for (int iFormat = 0; iFormat < iCount; iFormat++)
hr = pConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc);
/* Examine the format, and possibly use it. */
hr = pConfig->SetFormat(pmtConfig);
pmtConfig->subtype = MEDIASUBTYPE_RGB24;
// Delete the media type when you are done.
// if ((pmtConfig.majortype == MEDIATYPE_Video) &&
// (pmtConfig.subtype == MEDIASUBTYPE_RGB24) &&
// (pmtConfig.formattype == FORMAT_VideoInfo) &&
// (pmtConfig.cbFormat >= sizeof (VIDEOINFOHEADER)) &&
// (pmtConfig.pbFormat != NULL))
// VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)pmtConfig.pbFormat;
// // pVih contains the detailed format information.
// LONG lWidth = pVih->bmiHeader.biWidth;
// LONG lHeight = pVih->bmiHeader.biHeight;
Tuesday, May 29, 2007 8:04 PMPerhaps your webcam doesn't have a preview pin?
Wednesday, May 30, 2007 7:51 AMHi. Thanks for the answer!
I managed to see the stream coming from my webcam by using GraphEdit and also by using the function RenderStream().
Unfortunately, the video format is in RGB24 and not in I420. In GraphEdit, I manage to call the dialog box which allows me to access to this parameter in a list box. But when I try to call this dialog box through my program, at the function FindInterface( ) the HRESULT returns E_NOINTERFACE.
I don't understand what I should do to configure the output stream of my webcam.
Please help me.
Thanks in advance.
Wednesday, May 30, 2007 8:31 AMAre you still calling FindInterface against the preview pin? What other options have you tried here?
Wednesday, May 30, 2007 8:55 AMI tried to call the webcam properties dialog box by using this code :
// Query the capture filter for the IAMVfwCaptureDialogs interface.
IAMVfwCaptureDialogs *pVfw = 0;
HRESULT hr = pCap->QueryInterface(IID_IAMVfwCaptureDialogs, (void**)&pVfw);
// Check if the device supports this dialog box.
if (S_OK == pVfw->HasDialog(VfwCaptureDialog_Source))
// Show the dialog box.
hr = pVfw->ShowDialog(VfwCaptureDialog_Format, hwnd);
And I get the same result for HRESULT hr = E_NOINTERFACE.
Moreover I look at the directshow help concerning the differents subtype for the video format, and I didn't find the I420 format. Do you know where I could find it in order to set my webcam into this format?
thanks in advance
Wednesday, May 30, 2007 2:08 PMProblem solved after a day of work! You were right my webcam didn't have a preview pin and I tried by passing the capture pin and it works fine now.