1.Using the System Device Enumerator
2.Enumerating Pins
3.Enumerating Media Types
A full AmCap sample (build baseclasses firstly)
Getting all available resolutions from webcam using c++ directshow
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++
1 answer
Sort by: Most helpful
-
Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
2022-11-24T06:55:42.33+00:00