I have problem with samplegrabber filter. My graph looks like this:
AsyncReader->Mpeg2Demuxer(1)->InfTee(0)->H264 Decoder->Video render
->InfTee(1)->SampleGrabber
->Mpeg2Demuxer(0)->AAC Decoder->Audio Render
I get video decoded and displayed, but samplegrabber returns black image...
My snapshot function :
void CMFCDirectshowCtrl::SnapShot()
{
HRESULT hr = dsp->pSampleGrabber->SetBufferSamples(TRUE);
if (FAILED(hr))
return ;
hr = dsp->pSampleGrabber->SetOneShot(TRUE);
if (FAILED(hr))
return ;
AM_MEDIA_TYPE MediaType;
ZeroMemory(&MediaType,sizeof(MediaType));
hr = dsp->pSampleGrabber->GetConnectedMediaType(&MediaType);
if (FAILED(hr))
return;
VIDEOINFOHEADER *pVideoHeader = (VIDEOINFOHEADER*)MediaType.pbFormat;
if (pVideoHeader == NULL)
return;
BITMAPINFO BitmapInfo;
ZeroMemory(&BitmapInfo, sizeof(BitmapInfo));
CopyMemory(&BitmapInfo.bmiHeader, &(pVideoHeader->bmiHeader),
sizeof(BITMAPINFOHEADER));
void *buffer = NULL;
HBITMAP hBitmap = ::CreateDIBSection(0, &BitmapInfo, DIB_RGB_COLORS,
&buffer,
NULL, 0);
GdiFlush();
long buffsize = 0;
hr = dsp->pSampleGrabber->GetCurrentBuffer(&buffsize,(long *)buffer);
CBitmap bmp;
bmp.Attach(hBitmap);
BITMAP bitmap;
bmp.GetBitmap(&bitmap);
int size = bitmap.bmWidth*bitmap.bmHeight*bitmap.bmBitsPixel/8;
BYTE *lpBits = new BYTE[size];
::GetBitmapBits(hBitmap,size,lpBits);
WriteBmp("e:\\mreza\\output.bmp",&bitmap,(int*)lpBits);
delete []lpBits;
}
//-------------------------------------------------------------------------------
I dont receive any error msg, it just creates black image with correct image
size.
I've tried to create that graph in GraphEditor and when i execute it creates
one more H264 decoder after SampleGrabber. I tried to do same thing in my
code but put decoder before sample grabber, and than i get error msg when i
call GetConnectedMediaType function. Error is : 0x80040209 ...
1) your samplegrabber is in the wrong place. At this place you are
capturing compressed H264 stream.... You need to insert it after the
H264 decoder (set the samplegrabber capture mediatype as 24 or 32 bit
video).
2) after setting the parameters on the samplegrabber (one shot, etc, )
you must run the graph.
Application is first initialize graph, than it plays video in one screen
(thats why i use inftee, to split h264 on two decoders. one for playback and
other for snapshot). Than, when user clicks on snapshot button it calls
snapshot function as showed in previous post.
I have also put setbuffersamples and setoneshot function into intilialize
function, so graph is running before calling GetConnectedMediaType.
But i still get same error msg from that call.
"Michel Roujansky - Senior developer, Starfish Technologies Ltd"
<jeremi...@yahoo.com> wrote in message
news:bb0297d4-aa86-48c0...@s1g2000pra.googlegroups.com...
EInfTeeOutGrabber = GetOutPin( pEInfTee, 1);
SampleDecoderInput = GetInPin (pH264DecoderSample, 0);
hr = pGraph->Connect( EInfTeeOutGrabber, SampleDecoderInput ); //this call
doesnt retun S_OK
Both pins are refering to some memory address, so on first sight looks ok.
Do i need to run graph to create second output of inf tee ?
"Gossamer" <cbin...@WITHOUT.gmail.com> wrote in message
news:g9op3p$oo4$1...@news1.carnet.hr...
HRESULT hr = pFilter->EnumPins(&pEnum);
if(FAILED(hr))
return hr;
ULONG ulFound;
IPin *pPin;
hr = E_FAIL;
while(S_OK == pEnum->Next(1, &pPin, &ulFound))
{
PIN_DIRECTION pindir = (PIN_DIRECTION)3;
pPin->QueryDirection(&pindir);
if(pindir == dirrequired)
{
if(iNum == 0)
{
*ppPin = pPin; // Return the pin's interface
hr = S_OK; // Found requested pin, so clear error
break;
}
iNum--;
}
pPin->Release();
}
return hr;
}
//-------------------------------------------------------------------------------
IPin * DSPlayer::GetInPin( IBaseFilter * pFilter, int nPin )
{
CComPtr<IPin> pComPin=0;
GetPin(pFilter, PINDIR_INPUT, nPin, &pComPin);
return pComPin;
}
IPin * DSPlayer::GetOutPin( IBaseFilter * pFilter, int nPin )
{
CComPtr<IPin> pComPin=0;
GetPin(pFilter, PINDIR_OUTPUT, nPin, &pComPin);
return pComPin;
}
2. I have two instances of Decoder interface so i guess it should be
different pins ..
3. I'm not sure about that .. do i need to run graph to set next output or ?
"Mitesh Shah" <ms...@tdvisioncorp.com> wrote in message
news:eSLmPVuD...@TK2MSFTNGP05.phx.gbl...
"Gossamer" <cbin...@REM--gmail.com> wrote in message
news:ga3ki1$b1r$1...@news1.carnet.hr...
"Mitesh Shah" <ms...@tdvisioncorp.com> wrote in message
news:eWysVtfE...@TK2MSFTNGP03.phx.gbl...
> The error code i'm receiving after connect call is: Couldn't create system
> enumerator! hr=0x80040217
That's not the error description.
HRESULT: 0x80040217 (2147746327)
Name: VFW_E_CANNOT_CONNECT
Description: No combination of intermediate filters could be found to make
the connection.
Severity code: Failed
Facility Code: FACILITY_ITF (4)
Error Code: 0x0217 (535)
Use the DxErr tool that comes with the DX SDK.
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution