Same problem
- From: Kris Bujold
- Date: Thu, 12 Nov 2009 07:08:53 -0800
I have the same problem, have you figured it out?
Thanks,
Kristine
SkyWaLKer wrote:
Just found out that HTC devices ship with a filter named "HTC SourceFilter".
07-Jun-07
Just found out that HTC devices ship with a filter named "HTC Source
Filter". Somewhere on directx.audio group I found out that someone had
delved into it a bit and found that it was a capture filter from HTC
(both audio and video). I checked in registry and that is true. So, it
must be some optimized filter that we can use for capture.
Now, I tried to enumerate the pins on this capture filter, for which I
have to first query for an IPersistPropertyBag interface on this
filter (used the clsid of the filter from the registry and
CoCreateInstance for it returns S_OK). But the QueryInterface returns
E_NOINTERFACE. Any opinions/suggestions here? Because the registry
clearyly shows that this is a capture filter. Is there any other way I
can use this filter?
---My Code---
HRESULT hResult = S_OK;
IGraphBuilder *pFilterGraph;
ICaptureGraphBuilder2 *pCaptureGraphBuilder;
htcDDR.Data1 = 0xA06DF275;
htcDDR.Data2 = 0xC4F3;
htcDDR.Data3 = 0x46C7;
htcDDR.Data4[0] = 0xB5;
htcDDR.Data4[1] = 0x20;
htcDDR.Data4[2] = 0x3A;
htcDDR.Data4[3] = 0x16;
htcDDR.Data4[4] = 0xB3;
htcDDR.Data4[5] = 0xD1;
htcDDR.Data4[6] = 0xB8;
htcDDR.Data4[7] = 0xC2;
hResult = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder,(void**)&pFilterGraph);
hResult = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL,
CLSCTX_INPROC, IID_ICaptureGraphBuilder2,
(void**)& pCaptureGraphBuilder);
hResult = pCaptureGraphBuilder->SetFiltergraph( pFilterGraph );
IBaseFilter *pVideoCaptureFilter;
hResult=CoCreateInstance(htcDDR, NULL, CLSCTX_INPROC,
IID_IBaseFilter,
(void**)&pVideoCaptureFilter);
IPersistPropertyBag *pPropertyBag;
hResult=pVideoCaptureFilter->QueryInterface( IID_IPersistPropertyBag,
(void**) &pPropertyBag );
/* This is where I get the E_NOINTERFACE*/
---------------
Regards
Shantanu
On Jun 4, 5:42 pm, SkyWaLKer <shantanu.g...@xxxxxxxxx> wrote:
Previous Posts In This Thread:
On Saturday, June 02, 2007 11:06 AM
SkyWaLKer wrote:
Video Capture Performance with directshow
Hi
I'm writing a directshow based solution for capturing window (target
is WM 5.0). Its in native code.
Now, I've been able to get it all together after reading through
sample code on msdn and bits of info scattered here and there. But my
problem is:
1. When I run it on my Pocket PC, the available RAM (Program Memory)
diminshes rapidly irrespective of the time for which capturing is
done. It drops down to alarmingly low level (to around just 2 MB free
ram remaining) and then the app conks out. BTW, the output file size
is always a few KBs, so dont kjnow why so much ram is eaten.
2. No matter how long I wait between starting and stopping the control
stream, the recorded video comes out to be juse a couple of seconds at
max.
Basically what I'm doing in my code for starting stopping capture is:
________________CODE________________
hResult=pFilterGraph->QueryInterface(&pMediaControl);
hResult =pMediaControl->Run();
OAFilterState state = State_Stopped;
while(state != State_Running)
pMediaControl->GetState(100, &state);
LONGLONG dwStart = 0, dwEnd = 0;
WORD wStartCookie = 1, wEndCookie = 2;
dwEnd=MAXLONGLONG;
//start capturing
hResult=pCaptureGraphBuilder->ControlStream(
&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVideoCaptureFilter,
&dwStart, &dwEnd, 0, 0 );
Sleep(30000);
//Stop capturing
dwStart=0;
IMediaSeeking *pMediaSeeking;
hResult=pFilterGraph->QueryInterface(&pMediaSeeking );
hResult=pMediaSeeking->GetCurrentPosition( &dwEnd );
hResult= pCaptureGraphBuilder->ControlStream(
&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVideoCaptureFilter,
&dwStart, &dwEnd, wStartCookie, wEndCookie );
long leventCode, param1, param2;
hResult =pFilterGraph->QueryInterface( IID_IMediaEventEx, (void**)
&pMediaEvent );
hResult = pMediaControl->Stop();
_________________CODE______________________
So, please help me out as to :
1. How to avoid the memory loss while recording?
2. How to record for a longer length?
Regards
Shantz
On Saturday, June 02, 2007 1:34 PM
Michel Roujansky - DirectShow Consultant and Trainer wrote:
You do not show how you build the graph, and what it looks like.
You do not show how you build the graph, and what it looks like. Also
do you have an event sink? Why do you query IMediaEventEx just before
stopping?
Without the above information, my guess is that your PC is not
powerfull enough to capture and compress in realtime. So your app
buffers samples in RAM which gets exhausted quickly and the it dies.
Look at CPU utilization.
Also the controlstream is more or less useless the way you use it. You
could remove it alltogether.
On Saturday, June 02, 2007 2:54 PM
SkyWaLKer wrote:
Re: Video Capture Performance with directshow
On Jun 2, 10:34 pm, Michel Roujansky - DirectShow Consultant and
Trainer <jeremiah_...@xxxxxxxxx> wrote:
Hi
Actually, My target is WM 5.0 as I mentioned in my initial post, so,
yes, the CPU isnt powerful enough to capture and compress in realtime,
which raises another question. But first the info u asked (The code is
poorly done right now but I just wanted a proof of concept ready first
because this is just a small part in the bigger scehme of things):
Main Points:
1. I found out that my code was not getting the
EC_STREAM_CONTROL_STOPPED, because of which memory was exhausted and
code was stuck in loop, so put in a forced stop to the graph after
waiting for some time.
2. I also read in the documentation that controlstream is not needed
for asf file capture but without this somehow I never capture
anything. Please tell me the correct way of doing it.
3. Why is the encoding done only after capturing is stopped? Because
after stopping the capture I have to wait for a significantly long
time to complete the encode process. The OEM camera app must be doing
it differently, even the cecamera example from MS (which uses the
SHCamera APIs), because in both these cases there is no delay after
stopping the capture and getting the encoded file written.
Regards
Shantanu
-------------------------Code------------------
HRESULT hResult = S_OK;
IGraphBuilder *pFilterGraph;
ICaptureGraphBuilder2 *pCaptureGraphBuilder;
hResult = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder,(void**)&pFilterGraph);
hResult = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL,
CLSCTX_INPROC, IID_ICaptureGraphBuilder2,
(void**)& pCaptureGraphBuilder);
hResult = pCaptureGraphBuilder->SetFiltergraph( pFilterGraph );
IBaseFilter *pVideoCaptureFilter;
hResult=CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC,
IID_IBaseFilter,
(void**)&pVideoCaptureFilter);
IPersistPropertyBag *pPropertyBag;
hResult=pVideoCaptureFilter->QueryInterface( &pPropertyBag );
DEVMGR_DEVICE_INFORMATION devInfo;
CComVariant CamName;
CPropertyBag PropBag;
GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93,
0x3E, 0x4D, 0x7E, 0x3C, 0x86 };
devInfo.dwSize = sizeof(devInfo);
FindFirstDevice( DeviceSearchByGuid, &guidCamera, & devInfo);
CamName=devInfo.szLegacyName;
PropBag.Write( _T("VCapName"), &CamName );
pPropertyBag->Load( &PropBag, NULL );
hResult =pFilterGraph->AddFilter( pVideoCaptureFilter,
_T("Video Capture Filter") );
pPropertyBag->Release();
IBaseFilter *pVideoEncoder;
IDMOWrapperFilter *pWrapperFilter;
hResult=CoCreateInstance(CLSID_DMOWrapperFilter, NULL,CLSCTX_INPROC,
IID_IBaseFilter, (void**)&pVideoEncoder);
hResult =pVideoEncoder->QueryInterface( &pWrapperFilter );
hResult =pWrapperFilter->Init( CLSID_CWMV9EncMediaObject,
DMOCATEGORY_VIDEO_ENCODER );
hResult=pFilterGraph->AddFilter( pVideoEncoder, L"WMV9DMO Encoder");
IBaseFilter *pASFMultiplexer;
IFileSinkFilter *pFileSinkFilter;
hResult = pCaptureGraphBuilder->SetOutputFileName(
&MEDIASUBTYPE_Asf, _T("\\Storage Card\\test\\test.asf"),
&pASFMultiplexer,
&pFileSinkFilter );
hResult = pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
pVideoCaptureFilter,
pVideoEncoder,
pASFMultiplexer );
IMediaControl *pMediaControl;
IMediaEventEx *pMediaEvent;
hResult=pFilterGraph->QueryInterface(&pMediaControl);
hResult =pMediaControl->Run();
OAFilterState state = State_Stopped;
while(state != State_Running)
pMediaControl->GetState(100, &state);
LONGLONG dwStart = 0, dwEnd = 0;
WORD wStartCookie = 1, wEndCookie = 2;
dwEnd=MAXLONGLONG;
//start capturing
hResult=pCaptureGraphBuilder->ControlStream(
&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVideoCaptureFilter,
&dwStart, &dwEnd, 0, 0 );
Sleep(20000);
//Stop capturing
dwStart=0;
IMediaSeeking *pMediaSeeking;
hResult=pFilterGraph->QueryInterface(&pMediaSeeking );
hResult=pMediaSeeking->GetCurrentPosition( &dwEnd );
hResult= pCaptureGraphBuilder->ControlStream(
&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVideoCaptureFilter,
&dwStart, &dwEnd, wStartCookie, wEndCookie );
long leventCode, param1, param2;
hResult =pFilterGraph->QueryInterface( IID_IMediaEventEx, (void**)
&pMediaEvent );
/*Added a forceful stop here because was not getting the stream stop
event*/
Sleep(200000);
pMediaControl->Stop();
while(1)
{
hResult=pMediaEvent->GetEvent(&leventCode, ¶m1, ¶m2, 0);
if (EC_STREAM_CONTROL_STOPPED == leventCode)
{
pMediaControl->Stop();
break;
}
else if( leventCode == EC_CAP_FILE_COMPLETED )
{
dwStart = 1;
break;
}
hResult = pMediaEvent->FreeEventParams(leventCode, param1, param2);
}
pVideoCaptureFilter->Release ();
pVideoEncoder->Release ();
pMediaEvent ->Release();
pMediaSeeking ->Release();
pASFMultiplexer->Release();
pFileSinkFilter->Release();
pWrapperFilter ->Release();
pFilterGraph->Release();
pCaptureGraphBuilder->Release();
}
-------------------------------------
Code------------------------------
On Monday, June 04, 2007 4:18 AM
Michel Roujansky - DirectShow Consultant and Trainer wrote:
Re: Video Capture Performance with directshow
On Jun 2, 8:54 pm, SkyWaLKer <shantanu.g...@xxxxxxxxx> wrote:
Because the CPU is too busy capturing. So it buffers the samples, and
does encoding when it becomes available!
I think you should specify an asf profile, with encoding speed, and
image size, so that the encoder does only what is needed and not a too
high bandwidth and image size encoding.
On Monday, June 04, 2007 8:42 AM
SkyWaLKer wrote:
Re: Video Capture Performance with directshow
On Jun 4, 1:18 pm, Michel Roujansky - DirectShow Consultant and
Trainer <jeremiah_...@xxxxxxxxx> wrote:
Thnx Michel, I was also thinking about "almost" the same thing. I was
using the IAMStreamConfig to configure the output of the capture
filter but it was not working, and then on reading I found out that
IAMStreamConfig just "suggests" the output format, finally it is based
on negotiation between the capture filter and the mux filter, so I'd
have to use the IConfigAsfWriter to configure an appropriate profile.
Now, I dont have the Windows Media SDK, I have only the Windows Mobile
5.0 SDK and I can't find out the various Profile GUIDs and what
profile parameters do they actually correspond to. I can still set a
profile using the SetProfileUsingProfile method by creating a
IWmpProfile object myself but I need some reference to see what are
the parameters that make up a profile object. MSDN lists the names of
these parameters but from that I can't decipher how to fill the object
in code. Any suggestions?
Regards
Shantanu
On Thursday, June 07, 2007 2:51 PM
SkyWaLKer wrote:
Just found out that HTC devices ship with a filter named "HTC SourceFilter".
Just found out that HTC devices ship with a filter named "HTC Source
Filter". Somewhere on directx.audio group I found out that someone had
delved into it a bit and found that it was a capture filter from HTC
(both audio and video). I checked in registry and that is true. So, it
must be some optimized filter that we can use for capture.
Now, I tried to enumerate the pins on this capture filter, for which I
have to first query for an IPersistPropertyBag interface on this
filter (used the clsid of the filter from the registry and
CoCreateInstance for it returns S_OK). But the QueryInterface returns
E_NOINTERFACE. Any opinions/suggestions here? Because the registry
clearyly shows that this is a capture filter. Is there any other way I
can use this filter?
---My Code---
HRESULT hResult = S_OK;
IGraphBuilder *pFilterGraph;
ICaptureGraphBuilder2 *pCaptureGraphBuilder;
htcDDR.Data1 = 0xA06DF275;
htcDDR.Data2 = 0xC4F3;
htcDDR.Data3 = 0x46C7;
htcDDR.Data4[0] = 0xB5;
htcDDR.Data4[1] = 0x20;
htcDDR.Data4[2] = 0x3A;
htcDDR.Data4[3] = 0x16;
htcDDR.Data4[4] = 0xB3;
htcDDR.Data4[5] = 0xD1;
htcDDR.Data4[6] = 0xB8;
htcDDR.Data4[7] = 0xC2;
hResult = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder,(void**)&pFilterGraph);
hResult = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL,
CLSCTX_INPROC, IID_ICaptureGraphBuilder2,
(void**)& pCaptureGraphBuilder);
hResult = pCaptureGraphBuilder->SetFiltergraph( pFilterGraph );
IBaseFilter *pVideoCaptureFilter;
hResult=CoCreateInstance(htcDDR, NULL, CLSCTX_INPROC,
IID_IBaseFilter,
(void**)&pVideoCaptureFilter);
IPersistPropertyBag *pPropertyBag;
hResult=pVideoCaptureFilter->QueryInterface( IID_IPersistPropertyBag,
(void**) &pPropertyBag );
/* This is where I get the E_NOINTERFACE*/
---------------
Regards
Shantanu
On Jun 4, 5:42 pm, SkyWaLKer <shantanu.g...@xxxxxxxxx> wrote:
EggHeadCafe - Software Developer Portal of Choice
Create the Dynamic HTML window using Java Script
http://www.eggheadcafe.com/tutorials/aspnet/2c451446-e610-4eaa-90c7-283d07d37dbc/create-the-dynamic-html-w.aspx
.
- Prev by Date: Parser filter unable to render on HTC device.
- Next by Date: Re: Source filter which receives MPEG2 Program Stream via network
- Previous by thread: Parser filter unable to render on HTC device.
- Next by thread: writing h264 into mp4 using mp4v2
- Index(es):
Relevant Pages
|