Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Virtual Camera

38 views
Skip to first unread message

1754...@qq.com

unread,
Mar 5, 2009, 5:07:20 AM3/5/09
to
Dear all
I am interesting in devloping virtual camera. And I download a
sample code from http://tmhare.mvps.org/downloads.htm
The source code is very good to our beginer. But the CPU
occupancy rate is very high. Could you give me a hand?

dominolog

unread,
Mar 5, 2009, 10:31:58 AM3/5/09
to
On 5 Mar, 11:07, 175444...@qq.com wrote:
> Dear all
>      I am interesting in devloping virtual camera. And I download a
> sample code fromhttp://tmhare.mvps.org/downloads.htm

>      The source code is very good to our beginer. But the CPU
> occupancy rate is very high. Could you give me a hand?

Hello

In your filter look up the method FillBuffer. There you set the sample
times for every frame you pass up to rendering filter. You have to
calculate correct sample times for appropiate delays. Other thing is
the fact that the rendering pin may omit those values and renders the
frames as fast as possible. In that case, you have to override the
DoBufferProcessingLoop method in your Pin class and introduce some
delays (up to the assumed Frame Rate). The default implementation of
DoBufferProcessingLoop just calls FillBuffer as fast as possible and
then passes the sample to the output Pin.

I hope this helps

Regards
Dominik

1754...@qq.com

unread,
Mar 5, 2009, 8:39:55 PM3/5/09
to


dominolog


Thank you for your reply..
I am dshow beginer. I built and registered this vcam.ax filter. I
added three filters in GraphEdit(Virtual cam, Smart Tee, Video
Renderer).
1.Connect with Virtual cam and Video Renderer.--> low CPU occupancy
rate.
2.Connect with Virtual cam and Smart Tee (Capture pin) and Video
Renderer. -->low CPU occupancy rate.
3.Connect with Virtual cam and Smart Tee (Preview pin) and Video
Renderer. -->high CPU occupancy rate.

HRESULT CVCamPin::Get( REFGUID guidPropSet, // Which property set.
DWORD dwPropID, // Which property in that set.
void *pInstanceData, // Instance data (ignore).
DWORD cbInstanceData, // Size of the instance data (ignore).
void *pPropData, // Buffer to receive the property data.
DWORD cbPropData, // Size of the buffer.
DWORD *pcbReturned // Return the size of the property.
)
{
if (guidPropSet != AMPROPSETID_Pin) return
E_PROP_SET_UNSUPPORTED;
if (dwPropID != AMPROPERTY_PIN_CATEGORY) return
E_PROP_ID_UNSUPPORTED;
if (pPropData == NULL && pcbReturned == NULL) return E_POINTER;

if (pcbReturned) *pcbReturned = sizeof(GUID);
if (pPropData == NULL) return S_OK; // Caller just wants
to know the size.
if (cbPropData < sizeof(GUID)) return E_UNEXPECTED;// The buffer
is too small.

*(GUID *)pPropData = PIN_CATEGORY_CAPTURE; ///////////// If I
replace PIN_CATEGORY_CAPTURE with PIN_CATEGORY_PREVIEW here,
/////////////
CPU occupancy rate will be low, But it can't capture in some software.
return S_OK;
}


Best Regrads
bifei

Tim Roberts

unread,
Mar 6, 2009, 1:42:38 AM3/6/09
to
1754...@qq.com wrote:
>
>I am dshow beginer. I built and registered this vcam.ax filter. I
>added three filters in GraphEdit(Virtual cam, Smart Tee, Video
>Renderer).
>1.Connect with Virtual cam and Video Renderer.--> low CPU occupancy
>rate.
>2.Connect with Virtual cam and Smart Tee (Capture pin) and Video
>Renderer. -->low CPU occupancy rate.
>3.Connect with Virtual cam and Smart Tee (Preview pin) and Video
>Renderer. -->high CPU occupancy rate.

Right. That's how it's supposed to work. With a capture pin, the renderer
acknowledges the timestamps, and adds delays so that frames display at the
time they are supposed to display.

With a preview pin, the renderer displays frames as fast as they arrive,
ignoring the timestamps. Since your filter is generating frames infinitely
fast, this takes 100% CPU.

If you want your virtual cam to produce frames at a rate approximating a
real camera, then you'll have to insert the delays yourself.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

1754...@qq.com

unread,
Mar 8, 2009, 9:26:23 PM3/8/09
to
On 3月6日, 下午2时42分, Tim Roberts <t...@probo.com> wrote:
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

Thank you

0 new messages