我想在directshow中创建一个过滤器,将o / p视频裁剪到某个感兴趣的区域。在[GetMediaType(int iPosition,CMediaType * pMediaType)“]中我通过使用[DIBSIZE]更改[biWidth,biHeight和biSizeImage]来指定pMediatype的视频标题后修改pMediatype的视频标题,详细信息就像这样
// pvih is a pointer to pMediaType->pbFormat of type videoheader
//pInVh is a pointer to CurrentMediaType().pbFormat of the i/p of type videoheader
pvih->rcSource = pInVh->rcSource;
pvih->rcTarget = pInVh->rcTarget;
//bitmap settings
pvih->bmiHeader.biWidth = _Width;//width of region of interest
pvih->bmiHeader.biHeight = _Height;// height of region of interest
m_Width=pInVh->bmiHeader.biWidth;
m_Height=pInVh->bmiHeader.biHeight;
pvih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pvih->bmiHeader.biPlanes = 1; //1 image plane
pvih->bmiHeader.biBitCount = 24; //24bit
pvih->bmiHeader.biCompression = BI_RGB; //simply three values
pvih->bmiHeader.biSizeImage = DIBSIZE(pvih->bmiHeader);
//mediatype settings
pMediaType->majortype = MEDIATYPE_Video; //a video stream
pMediaType->subtype = MEDIASUBTYPE_RGB24; //24bit rgb samples
pMediaType->bFixedSizeSamples = true; //no varying size
pMediaType->bTemporalCompression = false; //no compression
pMediaType->formattype = FORMAT_VideoInfo; //VIDEOINFOHEADER
pMediaType->lSampleSize = pvih->bmiHeader.biWidth * pvih->bmiHeader.biHeight * pvih- >bmiHeader.biBitCount / 8; //size of one sample in bytes
pMediaType->cbFormat = sizeof(VIDEOINFOHEADER); //additiona format setting
但是当我用原始帧的样本填充裁剪框架时,o / p视频是垃圾,我也尝试用恒定颜色填充它,o / p不正确,任何想法如何解决这个问题??