用Dspack播放视频文件时怎么改动分辨率?并正确地截图? 提供1200分. ( 积分: 300 )

Unregistered / Unconfirmed
GUEST, unregistred user!
使用如下代码可以设置摄像头的分辨率,但如果播放视频文件时,更改分辨率却出错了。
这个问题可以有1200分。
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
bmp:TBitmap;
vcf:IAMStreamConfig;
pvih:pVideoInfoHeader;
aMediaType:pAMMediaType;
cgb:ICaptureGraphBuilder2;
begin

FilterGraph1.ClearGraph;
FilterGraph1.Active := False;
FilterGraph1.Active := True;
FilterGraph1.RenderFile('E:/Music/vcd/AVSEQ09.DAT');
FilterGraph1.Play;
cgb:=FilterGraph1 as ICaptureGraphBuilder2;//异常:Interface not supported.
if Succeeded(cgb.FindInterface(@PIN_CATEGORY_VIDEOPORT_VBI,nil,Filter1 as IBaseFilter,IAMStreamConfig,vcf)) then

begin

New(aMediaType);
vcf.GetFormat(aMediaType);
pvih:=PVideoInfoHeader(aMediaType.pbFormat);
pvih.bmiheader.biwidth:=160;
pvih.bmiheader.biheight:=120;
pVih.bmiHeader.biSizeImage:=160*120*pVih.bmiHeader.biBitCount div 8;//必要
vcf.SetFormat(aMediaType^);
DeleteMediaType(aMediaType);
end;

with(Self.FilterGraph1 as ICaptureGraphBuilder2)do
begin

RenderStream(@PIN_CATEGORY_CAPTURE, nil, Self.Filter1 as IBaseFilter,
Self.SampleGrabber1 as IBaseFilter, Self.VideoWindow1 as IbaseFilter);
end;

Self.FilterGraph1.Play;

bmp:=TBitmap.Create;
try
Self.SampleGrabber1.GetBitmap(bmp);
Self.Image1.Picture.Graphic:=bmp;
Self.Memo1.Lines.Add(Format('W:%D H:%D',[bmp.Width,bmp.Height]));
finally
bmp.Free;
end;

end;
 
有人看,没人解答一下吗?
 
var
nHeight,nWidth:integer;
basicvideo:IBasicVideo;
PinList:TPinList;
i:integer;
begin

if filtergraph.Active then

begin

if succeeded(FilterGraph.QueryInterface(IID_IBasicVideo,BasicVideo)) then

begin

BasicVideo.get_VideoWidth(nwidth);

BasicVideo.get_VideoHeight(nheight);
StatusBar2.Panels[1].Text:=(inttostr(nWidth)+' x '+inttostr(nHeight));
end;

end;

//if dsutil.HaveFilterPropertyPage(vFilter as IBaseFilter,ppDefault) then

// ShowFilterPropertyPage(self.Handle,vFilter as IBaseFilter,ppdefault);
FilterGraph.Stop;
Pinlist:=TPinList.Create(vFilter as IBaseFilter);
for i:=0 to PinList.Count-1do

begin

if PinList.Connected then


// ShowMessage();
ShowPinPropertyPage(self.Handle,PinList.Items);
end;


PinList.Free;
FilterGraph.Play;

end;
 
procedure TVideoForm.BitBtn2Click(Sender: TObject);
var
nHeight,nWidth:integer;
basicvideo:IBasicVideo;
PinList:TPinList;
i:integer;
begin

if filtergraph.Active then

begin

if succeeded(FilterGraph.QueryInterface(IID_IBasicVideo,BasicVideo)) then

begin

BasicVideo.get_VideoWidth(nwidth);

BasicVideo.get_VideoHeight(nheight);
StatusBar2.Panels[1].Text:=(inttostr(nWidth)+' x '+inttostr(nHeight));
end;

end;

if dsutil.HaveFilterPropertyPage(vFilter as IBaseFilter,ppDefault) then

ShowFilterPropertyPage(self.Handle,vFilter as IBaseFilter,ppdefault);
FilterGraph.Stop;
Pinlist:=TPinList.Create(vFilter as IBaseFilter);
for i:=0 to PinList.Count-1do

begin

if PinList.Connected then

PinList.Items.ConnectionMediaType(VideoMediaTypes.Items[VST.videoFmt.uid].AMMediaType^) ;
// ShowMessage();
// ShowPinPropertyPage(self.Handle,PinList.Items);
end;


PinList.Free;
FilterGraph.Play;

end;
 
截图好像DSPACK有个函数自动就截了,具体忘了。。。呵呵。。。
 
楼上去查一查。我看看spd260的代码,看看能否行得通的。
 
TO: spd260
VideoMediaTypes 是什么类型,没有交待的。代码我试了,出现Interface not supported的异常。
 
var
i:integer;
PinList:TPinList;
begin

FilterGraph1.Stop;
Pinlist:=TPinList.Create(Filter1 as IBaseFilter);
for i:=0 to PinList.Count-1do

ShowPinPropertyPage(self.Handle,PinList.Items);
PinList.Free;
FilterGraph1.Play;
end;
 
播放文件时看起来好象不支持更改视频分辨率的。那只好对视频图像进行变化分辨率,再进行处理的。
 
修改分辨率是可以的,注意连接的时候的媒体类型,自己做个 Resize Filter就可以了,
File Source->Decoder->Resize->VideoWindow
 
你写个例子一下。
 
这个很容易实现的,找找,有现成的.
 
顶部