const MaxPixelCount = 65536; type //Pf24bit真彩色位图像素数据结构体 pRGBTripleArray = ^TRGBTripleArray; TRGBTripleArray = array[0..MaxPixelCount - 1] of TRGBTriple; var VideoForm: TVideoForm; SysDev: TSysDevEnum; FrameBuf:array [0..352*288*3 ] of Byte; FrameImg:array [0..352*288*3 ] of Byte; FrameSequece : LongWord= 0; spf:TFileStream; xvid_Version:Integer; FrameByteCount : LongWord = 0; CurFrame: LongWord = 0; implementation
{$R *.dfm}
procedure TVideoForm.FormCreate(Sender: TObject); var i: integer; Device: TMenuItem; begin xvid_Version :=XVID_MAKE_VERSION(1,1,0); SysDev:= TSysDevEnum.Create(CLSID_VideoInputDeviceCategory); if SysDev.CountFilters > 0 then for i := 0 to SysDev.CountFilters - 1 do begin Device := TMenuItem.Create(Devices); Device.Caption := SysDev.Filters[i].FriendlyName; Device.Tag := i; Device.OnClick := OnSelectDevice; Devices.Add(Device); end; end;
procedure TVideoForm.OnSelectDevice(sender: TObject); begin Self.DoubleBuffered := True; FilterGraph.ClearGraph; FilterGraph.Active := false; Filter.BaseFilter.Moniker := SysDev.GetMoniker(TMenuItem(Sender).tag); FilterGraph.Active := true; with FilterGraph as ICaptureGraphBuilder2 do begin RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter as IBaseFilter, SampleGrabber as IBaseFilter, VideoWindow as IbaseFilter); end; try //XVID库初始化操作 xvid_gbl.version := xvid_Version; //Version:1.1.0 xvid_gbl.cpu_flags := Word(XVID_CPU_FORCE or XVID_CPU_ASM);//0:自动检查CPU,XVID_CPU_FORCE or XVID_CPU_ASM:强制使用ASM汇编优化 xvid_gbl.debug := 0; //调试级别