Different approaches on getting captured video frames in DirectShow

好久不见. 提交于 2019-12-11 16:46:54

问题


I was using a callback mechanism to grab the webcam frames in my media application. It worked, but was slow due to certain additional buffer functions that were performed within the callback itself.

Now I am trying the other way to get frames. That is, call a method and grab the frame (instead of callback). I used a sample in CodeProject which makes use of IVMRWindowlessControl9::GetCurrentImage.

I encountered the following issues.

  1. In a Microsoft webcam, the Preview didn't render (only black screen) on Windows 7. But the same camera rendered Preview on XP.

Here my doubt is, will the VMR specific functionalities be dependent on camera drivers on different platforms? Otherwise, how could this difference happen?

  1. Wherever the sample application worked, I observed that the biBitCount member of the resulting BITMAPINFOHEADER structure is 32.

Is this a value set by application or a driver setting for VMR operations? How is this configured? Finally, which is the best method to grab the webcam frames? A callback approach? Or a Direct approach?

Thanks in advance,


回答1:


IVMRWindowlessControl9::GetCurrentImage is intended for occasional snapshots, not for regular image grabbing.

Quote from MSDN:

This method can be called at any time, no matter what state the filter is in, whether running, stopped or paused. However, frequent calls to this method will degrade video playback performance.

This methods reads back from video memory which is slow in first place. This methods does conversion (that is, slow again) to RGB color space because this format is most suitable for for non-streaming apps and gives less compatibility issues.

All in all, you can use it for periodic image grabbing, however this is not what you are supposed to do. To capture at streaming rate you need you use a filter in the pipeline, or Sample Grabber with callback.



来源:https://stackoverflow.com/questions/10631290/different-approaches-on-getting-captured-video-frames-in-directshow

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