Advertisement Jump to content


This topic is now archived and is closed to further replies.

Shannon Barber

DirectShow Performance Problem

This topic is 6341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been messing with DirectShow lately, and have a simple capture/playback app together. The problem I''ve having, is it takes nearly 100% of CPU to render the preview video. If I leave the IVideoWindow alone (i.e. a seperate window pops up for the preview), it works as expected. But if I set the owner window, it takes a great deal of processing power to render the window. I noticed that DShow has problems if the target window isn''t the same size as the preview/capture stream, so I change the size of my preview window to match the size of the video stream. Has anyone else encountered this problem? And what did you do about it?
	//Sets the child window

	//here we create a RECT in which to draw the child window on

	//Display the movie at the original size

	long lWidth, lHeight;
	//Set the Child to this position

	TESTHR(m_spVideoWindow->SetWindowPosition(0, 0, lWidth, lHeight));

	//Make the parent fit the preview

	int c = 12;
	MoveWindow(hWndRender_, c,c, lWidth, lHeight, FALSE);

Magmai Kai Holmlor - Not For Rent

Share this post

Link to post
Share on other sites
After more farting around than I''d like to admit, I worked this out (in case anyone else notices that the code in the DirectShow examples doesn''t work for $%*@!)

//Make the video rendering surface appear inside the hWndRender_ window


//Retrive the video stream resolution

CComPtr<IBasicVideo> spBasicVideo;
long vHeight, vWidth;
TESTHR(spBasicVideo->GetVideoSize(&vWidth, &vHeight));

//See what the current window size is

RECT rect;
GetWindowRect(hWndRender_, &rect);
long wWidth, wHeight;
wWidth = rect.right - rect.left;
wHeight = rect.bottom -;

//See what the available client area is (given the above window size)

GetClientRect(hWndRender_, &rect);
long cWidth, cHeight;
cWidth = rect.right - rect.left;
cHeight = rect.bottom -;

//Compute the required increase in window size to produce a client area equal to the video resolution

long nHeight, nWidth;
nWidth = wWidth + (vWidth - cWidth);
nHeight = wHeight + (vHeight - cHeight);

//Increase the window size

SetWindowPos(hWndRender_, NULL, 0, 0, nWidth, nHeight, SWP_NOMOVE | SWP_NOOWNERZORDER);

//Verify the results

GetClientRect(hWndRender_, &rect);
cWidth = rect.right - rect.left;
cHeight = rect.bottom -;
_ASSERT(cWidth == vWidth);
_ASSERT(cHeight == vHeight);

//Set the video render window equal to the video frame resolution

TESTHR(m_spVideoWindow->SetWindowPosition(0,0, vWidth, vHeight));

Magmai Kai Holmlor
- Not For Rent

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Hey! your problem with speed depend of your video card. If you have a card that can do stretching blits by 2D hardware rasterization, there´s no trouble. (the only card that i have seen with this property.- Voodoo-Banshee LightSpeed by STD)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!