I am developing a vi开发者_JS百科sual C++ video capture application using DirectShow. When I checked the media subtype of the AM_MEDIA_TYPE structure of the Capture filter's Output pin, I could see that different webcams capture data in different formats such as MEDIASUBTYPE_RGB24, MEDIASUBTYPE_MJPG etc.
Is there any way I can tell the Output pin to output data in a common format like MEDIASUBTYPE_RGB24? I don't want to include the deciphering of all the sub-types possible.
Request you to let me know if I have any way around to make all the Webcam captured data to a common type before passing it to the Encoder.
You attach an sink to the pin, which is fixed to the format you want to receive and then DirectShow inserts filters to translate the input type into the type you want to.
See this example.
In general, each camera produces data in its own peculiar format(s) with no guarantee that it can transcode within the capture driver to RGB24 or any other format. Of all formats, variations on YUV are most common since these formats are amenable to both display directly onscreen as well as feed into a downstream compression filter.
The example pointed out by @Christopher doesn't really address the question of how to control the capture format. Video capture filters use a unique set of interfaces to control the myriad output format possibilities.
Use IAMStreamConfig.SetFormat() to select the frame rate, dimensions, color space, and compression of the output streams (Capture and Preview) from a capture device.
Use IAMStreamConfig.GetStreamCaps() to determine what frames rates, dimensions, color spaces, and compression formats are available. Most cameras provide a number different formats.
精彩评论