views:

180

answers:

2

How do i render a web cam filter instead of video file? I am looking at the vmr9compositor example included in the directshow sdk. It renders a video file. I would like to stream in the feed from the webcam. It SEEMS like this should be possible, but I dont have much of a grasp on directshow.

It uses this method call currently:

hr = g_graph->RenderFile( pFileName, NULL );

Looking at the playcap example in the sdk which can display the web cam feed in a window, I see that it uses

hr = g_pCapture->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrcFilter, NULL, NULL));

to display the web cam stream. pSrcFilter is an IBaseFilter.

How can I can swap the video file in the vmr app with the web cam feed?

Windows XP, Visual Studio 2008 C++

A: 

I don't really understand what the playcap sample is not doing. RenderFile is the equivalent of calling AddSourceFilter, and then enumerating each output pin (using IEnumPins) and rendering each pin. RenderStream is a wrapper that locates the pin and then renders it. So what the playcap sample does to insert a source filter (from the capture moniker) and then render it (using RenderStream) is the live-source equivalent of RenderFile.

Geraint Davies
I need the web cam stream rendered with the direct3d like the video file is. When I call :g_pCapture->RenderStreamorg_graph->Render(camPin);It pops up a little window that display the camera feed instead of rendering it with direct3d
Mr Bell
+1  A: 

Enumerate the webcam (video capture) sources and create a source filter using the techniques explained here:

http://msdn.microsoft.com/en-us/library/dd377566%28v=VS.85%29.aspx

From there, you just connect it as a source filter into your graph.

More details here on video capture with DShow here. http://msdn.microsoft.com/en-us/library/dd407331%28v=VS.85%29.aspx

selbie
I have the camera as a source filter (i think). I think I must be missing how to connect it as a source filter into the graph. Can you elaborate on that point?
Mr Bell
check the project under the SDK in "samples"
rogerdpack