Regarding the scope of Sample Grabber in DirectShow

笑着哭i 提交于 2019-12-01 14:40:45

Sample Grabber does not change media type of the data, but if you set a preferred media type before connecting then it will require the input stream to be of that mediatype. Just use RenderStream (intelligent connect, not direct one) and DirectShow will insert required decoders or transformers, if they are present.

Take a look at the RGBFilters example in the directx sdk. For example one of the filters included is TransNull24. That filter will pass all samples unmodified, but is only able to connect when the input is MEDIASUBTYPE_RGB24. What you do is connect the webcam filter to the TransNull24, and the TransNull24 with the samplegrabber. If the webcam is able to output RGB24, that will be used. Otherwise a transform filter will be automatically added between the webcam and the TransNull24. Now you will only receive RGB24 in your samplegrabber, even if the webcam does not support that directly.

Of course you don't need RGB24, but you can simply modify the example filter and create your own TransNullI420 filter. I am not sure the standard color space conversion filter can output I420, so you might need to install ffdshow, en configure it to convert uncompressed video.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!