Article From:https://www.cnblogs.com/wainiwann/p/9060246.html
// Set parameters, p1= wide, p2= high, p3= frame rate
AM_MEDIA_TYPE *p = NULL;
IAMStreamConfig *pSC = NULL;
pCGB2->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVCap, 
    IID_IAMStreamConfig, (void **)&pSC);
pSC->GetFormat(&p);
VIDEOINFOHEADER *pHd = (VIDEOINFOHEADER *)p->pbFormat;
// The unit is 100ns, so each frame (10^7/p3) *100ns
pHd->AvgTimePerFrame = 10000000 / p3;
// I420format
pHd->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0');
pHd->bmiHeader.biWidth = p1;
pHd->bmiHeader.biHeight = p2;
// One pixel point 12 bit
pHd->bmiHeader.biBitCount = 12;
// Image size
pHd->bmiHeader.biSizeImage = p1 * p2 * 3 / 2;
// Image transmission rate, unit BPS
pHd->dwBitRate = pHd->bmiHeader.biSizeImage * 8 * p3;
// defined in wmsdkidl.h
p->subtype = WMMEDIASUBTYPE_I420;
p->lSampleSize = pHd->bmiHeader.biSizeImage;
pSC->SetFormat(p);
// free p
FreeAM_MEDIA_TYPE(p);
pSC->Release();

The type definition designed above:

Include the header file “wmsdkidl.h” in Windows Media Format 9 SDK.
The problem should be solved. There are I420 media types in the GUID definition

EXTERN_GUID(WMMEDIASUBTYPE_I420,  
0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);  
EXTERN_GUID(WMMEDIASUBTYPE_IYUV,  
0x56555949, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);

 When I use enumerated devices (DirectShow enumerated camera acquisition resolution in this article) to see how much frame rate is supported, the resolution is 10 frames, 20 frames, 25 frames, and 30 frames. DirectShow is a unit of 100 nanoseconds.The actual values obtained are 1000000, 500000, 4000000 and 3333333.

Original text: https://blog.csdn.net/thuyz/article/details/46762487

Leave a Reply

Your email address will not be published. Required fields are marked *