简体   繁体   中英

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.

Using Direct Show, my Logitech c920 webcam has 3 output pins:

  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.
  2. Still image capture (ie PIN_CATEGORY_STILL ) in I420 and RGB24 with just 1 FPS.
  3. Video capture (ie PIN_CATEGORY_CAPTURE or PIN_CATEGORY_PREVIEW ) in h264 with FPS from 5 to 30.

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.

Using Media Foundation, the same camera has 3 stream descriptors ( IMFPresentationDescriptor::GetStreamDescriptorCount ). Each stream descriptor provides IMFMediaTypeHandler that allows you to iterate over media types. So I have 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.
  2. Video capture (ie IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ) in i420 and RGB24 with just 1 FPS.
  3. Video capture (ie IMFMediaTypeHandler::GetMajorType == MFMediaType_Video ) in h264 with FPS from 5 to 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.

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. 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.

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. 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?

Yes, Mediafoundation doesn't have PIN_CATEGORY_STILL style attribute.

Perhaps you can assume that media type with only 1 fps is still capture.

EDIT

doing some more reseach, there is MF_CAPTURE_ENGINE_STREAM_CATEGORY_PHOTO_DEPENDENT

This applies to MFCaptureEngine and it's for Windows 8...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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