# DirectShow, something wrong with PREVIEW pins

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

## Recommended Posts

A few days ago I started prototyping an application which required the computer to see thuru a webcam. To do that, I had to go with DirectShow. Yeah, it isn't part of DirectX really, but I suspect this forum is the closest to Windows. I read the documentation for a few days and worked on the code to produce essentially a blank screen with camera output, as well as experimenting a bit with GraphEdit. At the end of yesterday, everything essentially boiled down to
HRESULT res = captureBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
source, NULL, renderer);
This greeted me with a nice capture. I hoped I could start immediately working at how to process the data, instead I had to turn me back at the horror of a capture getting stuck. It simply stopped acquiring with no apparent reason after a few seconds. I investigated the possibility of the graph somehow getting paused/stopped, I tried restarting it, I investigated other DirectShow events using IMediaControl with no success. I then looked at the DShow examples and found the way to let GraphEdit connect to my graph. Very neat stuff. It turns out that the graph generated by the above call is somewhat different from what I get when I try to connect the two pins in GraphEdit, with a Smart Tee filter being added immediately after the webcam, with its Preview pin connected to fetch Video Decoder's input pin. For first, I do not understand why having more information can be troublesome, but I just asked for the PREVIEW pin as above since this is what PREVIEW pins are for right? Anyway, the graph failed to deliver even in GraphEdit. Playing with it a bit, I tried using the CAPTURE pin instead and everything seemed to work. So, I went back to my program and changed to
HRESULT res = captureBuilder->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
source, NULL, renderer);
This just did it. Now everything seems to be almost ok. What's wrong with PREVIEW pins? Can someone share some experiences about them and the Smart Tee filter? Can someone reproduce the issue systems?

##### Share on other sites
Just a note though that capture pins don't drop frames if things get hairy and start falling behind.. Capture pins are for actual perfect video captures, not previewing. For webcams you probably still want to use the preview pin.

---
Michael Tanczos

##### Share on other sites
Yes, this was the reason why I started with preview pins.
However, some additional tests today revealed other information which left me confused, to say the least.

First of all,the graph as I initially designed in GraphEdit:
USB Peripheral,Acquisition --> MJPEG Decompressor --> Color Space Converter --> VMR9
This works perfectly. It was built mainly to deal manually with filters and better understand the problem behind.

A second try with graphedit, connecting directly the peripheral to the VMR9 and relying on Intelligent Connect, delivering:
USB Peripheral,Acquisition --> In ffdshow video decoder --> VMR9
This works perfectly as well. I looked up ffdshow and found out it has been dead since 2004. I didn't even know I had this codec on, I think a friend of mine suggested to use it for some reason. I am pretty sure this is the problem.

Up to yesterday, calling RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, source, NULL, renderer); resulted in
USB Peripheral,Acquisition --> Smart Tee, Preview --> In ffdshow --> VMR9
Which doesn't work. The thing that leaves me somewhat confused is that Intelligent Connect seems to work differently in graphedit that in code. This sounds somewhat wrong to me, but anyway
RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, source, NULL, renderer);
Resulted in perfectly fine capture, with the only difference in graph being ffdshow taking input from Smart Tee's CAPTURE pin. This is sort of weird but again, ffdshow shouldn't be there right?
I disabled ffdshow and I've got:
USB Peripheral,Acquisition --> In Smart Tee, preview --> AVI Decompressor --> AVI Decompressor 001 --> Color Space Converter --> VMR9
Which not only works perfectly but seems to be quite smoother than before!
I am rather sure I've never seen anything like that in the previous days.

Summing up:
The problem was likely to be caused by a largely obsolete filter, which was probably designed for file decode rather than stream decode.

Why intelligent connect works differently on graphedit wrt my app is still an open question, which I guess I'll leave as is.

As a final note, my webcam does expose only two output pins: the still image pin and the "acquisition" pin (in localized language string). I'm not sure whatever it's capture or preview... but I don't truly care now.

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632566
• Total Posts
3007107

×