我下载了两个源码一个程序是程序采集和 截图 录制成avi  一个是在局域网内视频聊天 我想把它做成 可以采集 录制 截图同时也能视频聊天 但是 我把两个程序加载到一起 可以截图 但是不能录制 因为 录制出来的avi大小是0kb  源码挺简单 希望达人帮忙这个是视频的传输的服务器源码:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,VFW, IdBaseComponent, IdComponent, IdUDPBase,
  IdUDPClient,jpeg;type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    IdUDPClient1: TIdUDPClient;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure IdUDPClient1Status(ASender: TObject;
      const AStatus: TIdStatus; const AStatusText: String);
    procedure Panel1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  CapWnd:THandle;         //定义捕获窗句柄
  CapParms:TcaptureParms; //用于设置设备属性的结构变量
  BMPINFO:TBitmapInfo;    //BMP图像信息
implementation{$R *.dfm}
function  FrameCallBack(hWnd: HWND; lpVHdr: PVIDEOHDR): LongInt;stdcall;
var  hd:Thandle;
     jpg:TJpegImage;
     memStream :TMemoryStream;
     Bitmap:TBitmap;
begin
   //将数据显在Image,
   Bitmap:=TBitmap.Create;
   Bitmap.Width :=BMPINFO.bmiHeader.biWidth;      // New size of Bitmap
   Bitmap.Height:=BMPINFO.bmiHeader.biHeight;
   hd:= DrawDibOpen;
   DrawDibDraw(hd,Bitmap.canvas.handle,0,0,BMPINFO.BmiHeader.biwidth,BMPINFO.bmiheader.biheight,@BMPINFO.bmiHeader,
                   lpVHdr^.lpData,0,0,BMPINFO.bmiHeader.biWidth,BMPINFO.bmiHeader.biheight,0);
   DrawDibClose(hd);
   //发送数据
   memStream := TMemoryStream.Create;
   jpg := TJpegImage.Create;
   jpg.Assign(Bitmap);
   jpg.CompressionQuality := 10;  //jpg压缩质量
   jpg.JPEGNeeded;
   jpg.Compress;
   jpg.SaveToStream(memStream);
   jpg.Free;
   //因为UDP数据包有大小限制,这里如果超出部分,就没有传输,完全可以发几次发出去
   Form1.IdUDPClient1.BroadcastEnabled:=true;//用广播功能
   if memStream.Size>Form1.IdUDPClient1.BufferSize then
        //向192.168.0.X网段广播,端口 9001
        Form1.IdUDPClient1.SendBuffer('192.168.0.255',9001,memStream.Memory^,Form1.IdUDPClient1.BufferSize)
   else
        Form1.IdUDPClient1.SendBuffer('192.168.0.255',9001,memStream.Memory^,memStream.Size);
   memStream.Free;
   Bitmap.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
      CapWnd := capCreateCaptureWindow('我的窗口',
            WS_VISIBLE or WS_CHILD,//窗口样式
            0,    //X坐标
            0,    //Y坐标
            panel1.Width,  //窗口宽
            panel1.Height, //窗口高
            panel1.handle, //窗口句柄
            0);    //通常为0
      if CapWnd = 0 then exit;
      //定义帧捕捉回调函数
      CapSetCallbackOnFrame(CapWnd,FrameCallBack);
      CapParms.dwRequestMicroSecPerFrame:=1;
      CapParms.fLimitEnabled:=FALSE;
      CapParms.fCaptureAudio:=FALSE;
      CapParms.fMCIControl:=FALSE;
      CapParms.fYield:=TRUE;
      CapParms.vKeyAbort:=VK_ESCAPE;
      CapParms.fAbortLeftMouse:=False;
      CapParms.fAbortRightMouse:=FALSE;
      //让设置生效
      CapCaptureSetSetup(capWnd,@CapParms,sizeof(TCAPTUREPARMS));
      CapPreviewRate(capWnd,33);  //设置预览视频的频率
      CapCaptureSequenceNoFile(capWnd); //如果要捕获视频流,则要使用函数来指定不生成文件,不然会自动生成AVI文件
      CapDriverConnect(CapWnd,0);  //连接摄像头设备,第二个参数是个序号,当系统中装有多个显示驱动程序时,其值分别依次为0到总个数如果有多个摄像头,那么就是0->1->2
      capGetVideoFormat(capWnd, @BMPINFO,sizeof(TBitmapInfo)); //取得视频图像数据头
      CapPreviewScale(capWnd,TRUE); //是否缩放
      CapOverlay(capWnd,true); //指定是否使用叠加模式,true为使用,否则为false
      CapPreview(capWnd,true);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
   capCaptureAbort(CapWnd); //停止捕获
   capDriverDisconnect(CapWnd); //将捕获窗同驱动器断开
end;procedure TForm1.IdUDPClient1Status(ASender: TObject;
  const AStatus: TIdStatus; const AStatusText: String);
beginend;procedure TForm1.Panel1Click(Sender: TObject);
beginend;end
这个是视频本地采集 截图和录像成avi 的源码:
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
var
  hWndC : THandle;
implementation{$R *.dfm}
const WM_CAP_START = WM_USER;
const WM_CAP_STOP = WM_CAP_START + 68;
const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const WM_CAP_SAVEDIB = WM_CAP_START + 25;
const WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const WM_CAP_SEQUENCE = WM_CAP_START + 62;
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63;
const WM_CAP_SET_OVERLAY =WM_CAP_START+ 51;
const WM_CAP_SET_PREVIEW =WM_CAP_START+ 50;
const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;
const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;
const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;
const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;
const WM_CAP_SET_SCALE=WM_CAP_START+ 53;
const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52;function capCreateCaptureWindowA(lpszWindowName : PCHAR; dwStyle : longint; x : integer;
y : integer;nWidth : integer;nHeight : integer;ParentWin : HWND;
nId : integer): HWND;STDCALL EXTERNAL 'AVICAP32.DLL';procedure TForm1.Button1Click(Sender: TObject);  //开始视频
 begin
        hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,Panel1.Left,Panel1.Top,Panel1.Width,Panel1.Height,Form1.Handle,0);
  if hWndC <> 0 then
   begin
      SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
      SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
      SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
      SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
      SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
      SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
       SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
       SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);  //停止视频
begin
  if hWndC <> 0 then begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
end;
end;procedure TForm1.Button3Click(Sender: TObject); //保存BMP
begin
if hWndC <> 0 then begin
SendMessage(hWndC,WM_CAP_SAVEDIB,0,longint(pchar('c:\test.bmp')));
end;
end;procedure TForm1.Button4Click(Sender: TObject); //开始录象
begin
if hWndC <> 0 then
begin
SendMessage(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0, Longint(pchar('c:\test.avi')));
SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
end;
end;procedure TForm1.Button5Click(Sender: TObject); //停止录象
begin
 if hWndC <> 0 then begin
SendMessage(hWndC, WM_CAP_STOP, 0, 0);
end;
end;procedure TForm1.Button6Click(Sender: TObject);
begin
close;
end;end.
来源: http://www.programbbs.com/bbs/tree12-28397-28397.htm