以下是源代码:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,VFW, IdBaseComponent, IdComponent, IdUDPBase,
  IdUDPServer, IdUDPClient,IdSocketHandle, IdAntiFreezeBase, IdAntiFreeze;type
   TVIDEO_DATA = packed record
    bKeyFrame : bool;
    nSampleNum : DWORD;
    nUsedSize : DWORD;
    Buf : Array[0..4084-1] of byte;
  end;
  
  TForm1 = class(TForm)
    PnV1: TPanel;
    PnV2: TPanel;
    Button1: TButton;
    Button2: TButton;
    Memo1: TMemo;
    IdUDPClient1: TIdUDPClient;
    IdUDPServer1: TIdUDPServer;
    IdAntiFreeze1: TIdAntiFreeze;
    procedure Button1Click(Sender: TObject);
    
  private
    { Private declarations }
      
  public
    { Public declarations }   
    dc:HDC;
    hdd:HDRAWDIB;
    BmpInfo,BmpInfo1:BITMAPINFO;
    hWndc:Thandle;    DataPoint:^byte;
    DataPoint1:^byte;
    //  DataPoint:Pchar;
   OutFormatSize:dword;
   BmpOutInfo:^BITMAPINFO;
   CapVar:TCOMPVARS;
   OutBufferSize:DWORD;   
  
   function InitCaptureParams : boolean;  end;var
  Form1: TForm1;
   function FrameCallBack(hWnd:HWND;lpVHdr:PVIDEOHDR):DWORD;stdcall;
 implementation{$R *.dfm}{ TForm1 }function Tform1.InitCaptureParams : boolean;begin
      result := False;
      zeromemory(@CapVar,sizeof(TCOMPVARS));
      CapVar.cbSize:=sizeof(CapVar); //必须指定cbSize为TCOMPVARS结构大小
      CapVar.dwFlags:=ICMF_COMPVARS_VALID;
      CapVar.cbState:=0;
      CapVar.fccHandler:=859189837;
      CapVar.fccType:=ICTYPE_VIDEO;
      CapVar.hic:=ICOpen(ICTYPE_VIDEO, CapVar.fccHandler, ICMODE_COMPRESS);
      if (CapVar.hic>0) then
      begin
         OutFormatSize:=ICCompressGetFormatSize(CapVar.hic,@BmpInfo);
         getmem(BmpOutInfo,OutFormatSize);
    
                  ICCompressGetFormat(CapVar.hic,@BmpInfo.bmiHeader,@BmpOutInfo.bmiHeader);
         OutBufferSize:=ICCompressGetSize(CapVar.hic,@BmpInfo.bmiHeader,@BmpOutInfo.bmiHeader);
         ICSeqCompressFrameStart(@CapVar,@BmpInfo);
         result := True;
      
      end
      else
      begin
        Showmessage('请先安装视频压缩编码器');
        Exit;
      end
end;function FrameCallBack(hWnd:HWND;lpVHdr:PVIDEOHDR):DWORD;stdcall;
 var
       bKeyFrame : BOOL ;
       Buf : PBYTE;
       VideoData : TVIDEO_DATA;
       OutActSize : dword;
begin
    OutActSize := form1.BmpOutInfo.bmiHeader.biSizeImage;
    Buf := ICSeqCompressFrame(@form1.CapVar,0,lpVHdr.lpData,@bKeyFrame,@OutActSize);
    result := 0;end;procedure TForm1.Button1Click(Sender: TObject);
begin
   hWndC:=capCreateCaptureWindowA('Capdfture Window',WS_CHILD or WS_VISIBLE,PnV1.Left,PnV1.Top,PnV1.Width,PnV1.Height,form1.Handle,0);
  if hWndC = 0 then exit;  capDriverConnect(hWndC,0);   //连接摄像头设备
  capDlgVideoFormat(hWndC);  //显示视频设置对话框,进行配置视频的大小、颜色位数等。
  capGetVideoFormat(hWndC,@BmpInfo,sizeof(BITMAPINFO));  //取得视频图像数据头,后面压缩时需要用到
  capPreviewRate(hWndC, 33);  //设置预览视频的频率,33代表第秒30帧。
  capPreview(hWndC, TRUE); 
  capSetCallbackOnFrame(hWndC,FrameCallBack);
  InitCaptureParams;
   
end;end.