简体   繁体   English

Media Foundation错误地将静止图像捕获流描述符标记为视频捕获

[英]Media Foundation is incorrectly marking still image capture stream descriptors as video capture

I'm doing video capture from a webcam in two separate ways (think two applications): using Direct Show and Media Foundation. 我正在以两种不同的方式(请考虑两个应用程序)从网络摄像头捕获视频:使用Direct Show和Media Foundation。

Using Direct Show, my Logitech c920 webcam has 3 output pins: 使用Direct Show,我的Logitech c920网络摄像头具有3个输出引脚:

  1. Video capture (ie PIN_CATEGORY_CAPTURE or PIN_CATEGORY_PREVIEW ) in I420, RGB24 and MJPG pixel formats, with FPS from 2 to 30, depending on media type. I420,RGB24和MJPG像素格式的视频捕获(即PIN_CATEGORY_CAPTUREPIN_CATEGORY_PREVIEW ),FPS为2到30,具体取决于媒体类型。
  2. Still image capture (ie PIN_CATEGORY_STILL ) in I420 and RGB24 with just 1 FPS. 在I420和RGB24中以1 FPS拍摄静态图像(即PIN_CATEGORY_STILL )。
  3. Video capture (ie PIN_CATEGORY_CAPTURE or PIN_CATEGORY_PREVIEW ) in h264 with FPS from 5 to 30. 在h264中以5到30的FPS进行视频捕获(即PIN_CATEGORY_CAPTUREPIN_CATEGORY_PREVIEW )。

So, since I'm concerned only with video capture, I ignore all pins that are not PIN_CATEGORY_CAPTURE or PIN_CATEGORY_PREVIEW , which works great. 因此,由于我只关注视频捕获,因此我忽略了所有非PIN_CATEGORY_CAPTUREPIN_CATEGORY_PREVIEW ,这很好用。

Using Media Foundation, the same camera has 3 stream descriptors ( IMFPresentationDescriptor::GetStreamDescriptorCount ). 使用Media Foundation,同一台摄像机具有3个流描述符( IMFPresentationDescriptor::GetStreamDescriptorCount )。 Each stream descriptor provides IMFMediaTypeHandler that allows you to iterate over media types. 每个流描述符都提供IMFMediaTypeHandler ,它允许您遍历媒体类型。 So I have 3 IMFMediaTypeHandlers: 所以我有3个IMFMediaTypeHandlers:

  1. Video capture (ie IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ) in I420, RGB24 and MJPG pixel formats, with FPS from 2 to 30, depending on media type. I420,RGB24和MJPG像素格式的视频捕获(即IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ),根据媒体类型,FPS为2到30。
  2. Video capture (ie IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ) in i420 and RGB24 with just 1 FPS. i420和RGB24中的视频捕获(即IMFMediaTypeHandler::GetMajorType == MFMediaType_Video )只有1 FPS。
  3. Video capture (ie IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ) in h264 with FPS from 5 to 30. h264中的视频捕获(即IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ),FPS为5到30。

You can notice that Media Foundation's stream descriptors seem to map to Direct Show's output pins 1 on 1. Except that Media Foundation didn't mark the stream descriptor #2 as still image capture ( MFMediaType_Image ), in contrast to what Direct Show is doing. 您可能会注意到,Media Foundation的流描述符似乎映射到Direct Show的输出针1到1。除了Direct Foundation所做的对比之外,Media Foundation没有将流描述符#2标记为静止图像捕获( MFMediaType_Image )。

Still image capture requires different handling than video capture, so my Direct Show code errors and doesn't do any capturing at all when trying to use media types from pin #2. 静止图像捕获需要与视频捕获不同的处理方式,因此,在尝试使用引脚2中的媒体类型时,我的Direct Show代码错误并且根本不进行任何捕获。 Well, I only care about video capturing in the first place, so that is fine. 好吧,我一开始只关心视频捕获,所以很好。

But even through Media Foundation tells that the stream descriptor #2 is video capture, my Media Foundation code, which works perfectly with all media types from steam descriptors #1 and #3, crashes on media types from stream descriptor #2, similarly to how Direct Show crashes on still image capture only. 但是,即使通过Media Foundation告诉流描述符#2是视频捕获,我的Media Foundation代码也可以与流描述符#2的媒体类型崩溃,该代码与流描述符#2和#3的所有媒体类型均能完美工作。 Direct Show仅在静止图像捕获时崩溃。

So I get the impression that it's either Media Foundation (or the Windows 7 webcam driver provided by Logitech ) is buggy and not marking stream descriptor #2 as still image capture when it should, or I'm checking the wrong flag to determine if it's video capture or still image capture. 因此,我得到的印象是它是Media Foundation(或Logitech提供的Windows 7网络摄像头驱动程序 )有故障,并且在应该时没有将流描述符#2标记为静止图像捕获,或者我正在检查错误的标志以确定它是否是视频捕获或静止图像捕获。 If it's my mistake, then what is the right way to differentiate between video (#1 and #3) and still image (#2) capture stream descriptors? 如果是我的错,那么区分视频(#1和#3)和静止图像(#2)捕获流描述符的正确方法是什么?

Yes, Mediafoundation doesn't have PIN_CATEGORY_STILL style attribute. 是的,Mediafoundation没有PIN_CATEGORY_STILL样式属性。

Perhaps you can assume that media type with only 1 fps is still capture. 也许您可以假设仅捕获1 fps的媒体类型。

EDIT 编辑

doing some more reseach, there is MF_CAPTURE_ENGINE_STREAM_CATEGORY_PHOTO_DEPENDENT 再做一些研究,有MF_CAPTURE_ENGINE_STREAM_CATEGORY_PHOTO_DEPENDENT

This applies to MFCaptureEngine and it's for Windows 8... 这适用于MFCaptureEngine,适用于Windows 8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM