var video_input_port:TPhysicalConnectorType;
procedure TVideoFormA.inputcomboxChange(Sender: TObject);
var i:Integer;
begin
i:=inputcombox.ItemIndex;
case i of
0:video_input_port:=PhysConn_Video_Tuner;
1: video_input_port:=PhysConn_Video_Composite;
2:video_input_port:=PhysConn_Video_SVideo;
3:video_input_port:=PhysConn_Video_RGB;
4:video_input_port:=PhysConn_Video_YRYBY;
5:video_input_port:=PhysConn_Video_SerialDigital;
6:video_input_port:=PhysConn_Video_ParallelDigital;
7:video_input_port:=PhysConn_Video_SCSI;
8:video_input_port:=PhysConn_Video_1394;
9:video_input_port:=PhysConn_Video_AUX ;
10:video_input_port:=PhysConn_Video_USB;
11:video_input_port:=PhysConn_Video_VideoDecoder;
12:video_input_port:=PhysConn_Video_VideoEncoder;
13:video_input_port:=PhysConn_Video_SCART;
14:video_input_port:=PhysConn_Video_Black;
end;
OnSelectDevice(Sender);
end;
procedure TVideoFormA.OnSelectDevice(sender:TObject);
var
pinlist:TPinList;
i:Integer;
sourcefilter:IBaseFilter;
capturegraph:ICaptureGraphBuilder2;
begin
FilterGraph.ClearGraph;
FilterGraph.Active := false;
bdev.SelectGUIDCategory(CLSID_VideoInputDeviceCategory);
Filter.FilterGraph:=FilterGraph;
Filter.BaseFilter.Moniker := bDev.GetMoniker(videosrccombox.ItemIndex);
FilterGraph.Active := true;
if Filter.FilterGraph <> nil then
begin
PinList := TPinList.Create(Filter as IBaseFilter);
if VideoFormat.ItemIndex <> -1 then
with (PinList.First as IAMStreamConfig)do
begin
SetFormat(VideoMediaTypes.Items[VideoFormat.ItemIndex].AMMediaType^);
end;
PinList.Free;
end;
FilterGraph.QueryInterface(icapturegraphbuilder2,capturegraph);
Filter.QueryInterface(ibasefilter,sourcefilter);
if SetVideoInput(video_input_port) <>S_OK then
raise
Exception.Create('video input connector not found');///端口选择
with FilterGraph as ICaptureGraphBuilder2do
RenderStream(@PIN_CATEGORY_PREVIEW,
nil,
Filter as IBaseFilter,
SampleGrabber as IBaseFilter,
VideoWindow as IbaseFilter);
FilterGraph.Play;
end;