Getting all available resolutions from webcam using c++ directshow

Ньюман Александр 1 Reputation point
2022-11-23T16:58:39.853+00:00

Hi, could anybody please help me to find full working code example of how to get all available resolutions from pc webcam?

I found this explanation, but it's not full

You can get supported resolutions without adding the capture source to a filter graph. You need to:

1. bind the device moniker to a base filter  
2. get an output pin from that filter  
3. enumerate over media types of that output pin  

Here is how to enumerate the media types given a media type enumerator:

AM_MEDIA_TYPE* mediaType = NULL;
VIDEOINFOHEADER* videoInfoHeader = NULL;
while (S_OK == mediaTypesEnumerator->Next(1, &mediaType, NULL))
{
if ((mediaType->formattype == FORMAT_VideoInfo) &&
(mediaType->cbFormat >= sizeof(VIDEOINFOHEADER)) &&
(mediaType->pbFormat != NULL))
{
videoInfoHeader = (VIDEOINFOHEADER*)mediaType->pbFormat;
videoInfoHeader->bmiHeader.biWidth; // Supported width
videoInfoHeader->bmiHeader.biHeight; // Supported height
}
FreeMediaType(*mediaType);
}

I don't understand how to:
1. bind the device moniker to a base filter
2. get an output pin from that filter
3. enumerate over media types of that output pin

Windows development | Windows API - Win32
Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2022-11-24T06:55:42.33+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.