웹캠이 640x480에서 프레임을 제공하고 있기 때문에 인코더가 고해상도로 올바르게 작동하지 않기 때문에 프레임 해상도를 320x240으로 변경하려고합니다.델파이 DirectShow에서 웹캠의 해상도 변경
샘플 그래버를 통해 프레임을 잡을 때
procedure OnDevieStart()
begin
FilterGraph.ClearGraph;
FilterGraph.Active := False;
Filter.BaseFilter.Moniker := SysDev.GetMoniker(TMenuItem(Sender).tag);
FilterGraph.Active := true;
SetVideoProperties(Filter as iBaseFilter);
with FilterGraph as ICaptureGraphBuilder2 do
try
RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter as IBaseFilter, SampleGrabber as IBaseFilter, VideoWindow as IbaseFilter);
FilterGraph.Play;
except
ShowMessage('Unable to use specified device!')
end;
end;
function SetVideoProperties(pVideoCapture: IBaseFilter):Boolean;
var
hr:HRESULT;
pStreamConfig: IAMStreamConfig;
pAM_Media: PAMMediaType;
pvih: PVIDEOINFOHEADER;
pICGP2: ICaptureGraphBuilder2;
begin
pICGP2 := FilterGraph as ICaptureGraphBuilder2;
hr := pICGP2.FindInterface(@PIN_CATEGORY_CAPTURE, nil, pVideoCapture,
IID_IAMStreamConfig, pStreamConfig);
if (SUCCEEDED(hr)) then begin
pStreamConfig.GetFormat(pAM_Media);
pvih := pAM_Media.pbFormat ;
pAM_Media.subtype := MEDIASUBTYPE_RGB24;
pvih.bmiHeader.biWidth := 320;
pvih.bmiHeader.biHeight := 240;
pvih.AvgTimePerFrame := 10000000 div 15;
pStreamConfig.SetFormat(pAM_Media^);
DeleteMediaType(pAM_Media);
pStreamConfig := nil;
end;
end;
그러나 해상도는이 방법 문제 있나요 동일하게 유지?
UPDATE
좋아, 내가 지금 모든 구성원
를 업데이트하고 생각function SetVideoProperties(pVideoCapture: IBaseFilter):Boolean;
var
hr:HRESULT;
pStreamConfig: IAMStreamConfig;
pAM_Media: PAMMediaType;
pvih: PVIDEOINFOHEADER;
pICGP2: ICaptureGraphBuilder2;
begin
pICGP2 := FilterGraph as ICaptureGraphBuilder2;
hr := pICGP2.FindInterface(@PIN_CATEGORY_CAPTURE, nil, pVideoCapture,
IID_IAMStreamConfig, pStreamConfig);
if (SUCCEEDED(hr)) then begin
pStreamConfig.GetFormat(pAM_Media);
pAM_Media.subtype := MEDIASUBTYPE_RGB24;
pAM_Media.majortype := MEDIATYPE_Video;
pAM_Media.bFixedSizeSamples := True;
pAM_Media.bTemporalCompression := False;
pAM_Media.lSampleSize := 230400;
pAM_Media.formattype := FORMAT_VideoInfo;
pAM_Media.pUnk := nil;
pAM_Media.cbFormat := 88;
pvih := pAM_Media.pbFormat;
pvih.dwBitRate := 6912000;
pvih.AvgTimePerFrame := 10000000 div 15;
pvih.bmiHeader.biSize := 40;
pvih.bmiHeader.biWidth := 320;
pvih.bmiHeader.biHeight := 240;
pvih.bmiHeader.biPlanes := 1;
pvih.bmiHeader.biBitCount := 24;
pvih.bmiHeader.biCompression := 0;
pvih.bmiHeader.biSizeImage := 230400;
pvih.bmiHeader.biXPelsPerMeter := 0;
pvih.bmiHeader.biYPelsPerMeter := 0;
pvih.bmiHeader.biClrUsed := 0;
pvih.bmiHeader.biClrImportant := 0;
hr := pStreamConfig.SetFormat(pAM_Media^);
If Succeeded(hr) then ShowMessage('SUCCEED') else ShowMessage(IntToStr(hr));
DeleteMediaType(pAM_Media);
pStreamConfig := nil;
end;
end;
내가 지금 모든 구성원을 업데이트하고 있지만, 여전히, 난 당신이 코드로 설명해 수 –