Get all supported FPS camera values ​​at Microsoft Media Foundation

I want to get a list of all the FPS values ​​supported by my webcam.

In How to set the frame rate of video capture , the msdn article says that I can request a system for the maximum and minimum supported FPS of a specific camera.

It also says:

The device may support other frame rates in this range.

And in MF_MT_FRAME_RATE_RANGE_MIN it says:

The device does not guarantee support for each increment in this range.

It seems that there is no way to get all the supported FPS values ​​by the camera in the Media Foundation, just max and min.

I know that on Linux the v4l2-ctl --list-formats-extcommand prints a lot more supported FPS than just min and max.

Here are some examples from Linux using different cameras:

$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
  Index       : 0
  Type        : Video Capture
  Pixel Format: 'YUYV'
  Name        : YUV 4:2:2 (YUYV)
    Size: Discrete 160x120
      Interval: Discrete 0.033s (30.000 fps)
      Interval: Discrete 0.036s (27.500 fps)
      Interval: Discrete 0.040s (25.000 fps)
      Interval: Discrete 0.044s (22.500 fps)
      Interval: Discrete 0.050s (20.000 fps)
      Interval: Discrete 0.057s (17.500 fps)
      Interval: Discrete 0.067s (15.000 fps)
      Interval: Discrete 0.080s (12.500 fps)
      Interval: Discrete 0.100s (10.000 fps)
      Interval: Discrete 0.133s (7.500 fps)
      Interval: Discrete 0.200s (5.000 fps)
    Size: Discrete 176x144
      Interval: Discrete 0.033s (30.000 fps)
      ...

and

$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUV 4:2:2 (YUYV)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.040s (25.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.040s (25.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.040s (25.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 160x120
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.040s (25.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 960x544
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.200s (5.000 fps)

and

$ v4l2-ctl --list-formats-ext    
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUV 4:2:2 (YUYV)
                Size: Discrete 1280x720
                        Interval: Discrete 0.111s (9.000 fps)
                Size: Discrete 160x120
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x800
                        Interval: Discrete 0.111s (9.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'MJPG' (compressed)
        Name        : MJPEG
                Size: Discrete 1280x720
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 160x120
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1280x800
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 640x480
                        Interval: Discrete 0.033s (30.000 fps)

So, is there a way to get all supported FPS using a camera in the Microsoft Media Foundation, or is it really limited in this aspect?

+4
source share
1 answer

The frame rate and other attributes can be obtained using a code similar to the following (error checking omitted for brevity):

Microsoft::WRL::ComPtr<IMFSourceReader> reader = nullptr;
/* reader code omitted */

IMFMediaType* mediaType = nullptr;
GUID          subtype { 0 };

UINT32 frameRate = 0;
UINT32 frameRateMin = 0;
UINT32 frameRateMax = 0;
UINT32 denominator = 0;
DWORD32 width, height;
DWORD index = 0;

HRESULT hr = S_OK;
while (hr == S_OK)
{
    hr = reader->GetNativeMediaType((DWORD) MF_SOURCE_READER_FIRST_VIDEO_STREAM, index, &mediaType);
    if (hr == MF_E_NO_MORE_TYPES)
        break;

    hr = mediaType->GetGUID(MF_MT_SUBTYPE, &subtype);
    hr = MFGetAttributeSize(mediaType, MF_MT_FRAME_SIZE, &width, &height);
    hr = MFGetAttributeRatio(mediaType, MF_MT_FRAME_RATE, &frameRate, &denominator);
    hr = MFGetAttributeRatio(mediaType, MF_MT_FRAME_RATE_RANGE_MIN, &frameRateMin, &denominator);
    hr = MFGetAttributeRatio(mediaType, MF_MT_FRAME_RATE_RANGE_MAX, &frameRateMax, &denominator);
    ++index;
}

. 32 , 32 . , 30 (fps), 30/1. 29,97 fps, 30 000/1001.

, 1 ( ). -, , frameRate, frameRateMin frameRateMax . , .

Edit:

, ( printf) , Logitech Webcam Pro 9000:

enter image description here

- 46 , - (C930e 216). 81 C930e:

enter image description here

- , , , , .. (I max 99 ).

, :

, min max , -, . , . PCIe 4 , , , ( min max).

+3

All Articles