Mr Bell
Mr Bell

Reputation: 9338

How do i render a web cam filter instead of video file in directshow?

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++

Upvotes: 2

Views: 2237

Answers (2)

selbie
selbie

Reputation: 104569

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

Upvotes: 2

Geraint Davies
Geraint Davies

Reputation: 2847

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.

Upvotes: 0

Related Questions