1

I have filters in Graphedit whose settings can be changed.

I have a usb webcam which i can go to its properties and make it stream at different sizes, but im not sure how i would change these types of options programmatically without popping up the actual webcam property box. I want to keep it stream lined in a sense.

.QueryFilterInfo()

didn't give me any access to those types of options, and neither did

.QueryPinInfo()

Is there a way to get access to these options in C#?

Update: http://sourceforge.net/projects/directshownet/forums/forum/460697/topic/1319584

shows you how to correctly use GetStreamCaps

Grant
  • 684
  • 1
  • 7
  • 26

1 Answers1

3

The interface you're looking for is IAMStreamConfig on the source filter's output pin This lets you specify fps and height and width, etc. Even though the link is for the c++ version, IAMStreamConfig is available in C# as it is listed here.

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
Ralf
  • 9,405
  • 2
  • 28
  • 46
  • will this force the camera into its other modes, ie 1280 x 720 or will this force its current format ( 640 x 480 ) into the defined mode and lose quality? – Grant Jun 24 '11 at 19:04
  • I'm not sure if I understand your question correctly. Using IAMStreamConfig you can a) call GetNumberOfCapabilities to get the count, then use that to iterate over the supported types by calling GetStreamCaps. Further to change the resolution one typically calls GetFormat to retrieve the current configured format, modifies this format and calls SetFormat with the modified AM_MEDIA_TYPE*. This modified type must be supported by the filter or else the call will fail. – Ralf Jun 25 '11 at 07:10
  • i mean would it make the camera change style from 640x480 to 1280x720 or will it just stretch 640x480 into a 1280x720 size? the latter produces loss of quality and viewing angle – Grant Jun 28 '11 at 22:04
  • It will change the resolution as long as the camera supports it. To see the resolutions supported by the USBcam, iterate over the media types as I explained above. Or use the property page in graphedit. – Ralf Jun 29 '11 at 10:03
  • found out that i basically have to stop the graph, stop rendering rebuild the graph to effectively change resolutions on the pin atleast. but it works :) – Grant Jun 30 '11 at 22:54
  • Yes, you would have to do that since image dimensions are negotiated when the graph is built. There is something called dynamic reconnection that might be of interest to you (http://msdn.microsoft.com/en-us/library/dd388737(v=vs.85).aspx). It allows for re-negotiation without rebuilding, but the filters in the graph need to support it AFAIR. – Ralf Jul 01 '11 at 04:39
  • 1
    Thanks for the answer. But for a beginner in Direct Show it is not really helpfull. Can you please tell me where I get the IAMStreamConfig interface from? In my code I have a IGraphBuilder, ICaptureGraphBuilder2, IBaseFilter, IVMRWindowlessControl9, IMediaControl. A peace of code would be VERY helpfull! – Elmue Apr 06 '16 at 15:15