我想作一个把从摄像头拍摄的内容存成AVI格式文件的程序,不知道这样写为什么不行?(50分)

R

rabaca

Unregistered / Unconfirmed
GUEST, unregistred user!
开始:
procedure CapSetVideoFileName( FileName : string );
begin

gCapVideoFileName := FileName;
end;

procedure CapStart;
var
achvideoFileName : array [0..255] of Char;
begin

if ghCapWnd = 0 then
exit;
StrPCopy(achvideoFileName, gCapVideoFileName);
capCaptureSequence( ghCapWnd );
end;

procedure CapSetCapSec( NofMaxVideoFrame : Integer );
begin

gdwCapNofMaxVideoFrame := DWord( NofMaxVideoFrame );
end;

(*---------------------------------------------------------------*)
(* -- 回凋函数 --- *)
(*---------------------------------------------------------------*)
function StatusCallbackProc(hWnd : HWND;
nID : Integer;
lpsz : LongInt): LongInt;
stdcall;
var
TmpStr : string;
dwVideoNum : dword;
begin


TmpStr := StrPas(PChar(lpsz));
gCapVideoInfoLabel.Caption := TmpStr;
gCapVideoInfoLabel.Refresh;

if nID = IDS_CAP_STAT_VIDEOCURRENT then

begin

dwVideoNum := StrToInt( Copy(TmpStr, 0, Pos(' ', TmpStr)-1));
if dwVideoNum >= gdwCapNofMaxVideoFrame then

begin

capCaptureAbort(ghCapWnd);
if @gCapStatusProcedure <> nil then
gCapStatusProcedure(nil);
end;

end;

Result := 1;
end;

function CapOpenDriver : Boolean;
var
Retc : LongInt;
DriverIndex : Integer;
DriverStarted : boolean;
achDeviceName : array [0..80] of Char;
achDeviceVersion : array [0..100] of Char;
achFileName : array [0..255] of Char;
begin

Result := FALSE;
if gCapVideoArea = nil then
exit;

Result := TRUE;
// 取得窗口
ghCapWnd := capCreateCaptureWindow( PChar('KruwoSoft'),
WS_CHILD or WS_VISIBLE, 0, 0,
gCapVideoArea.Width, gCapVideoArea.Height,
gCapVideoArea.Handle, 0);
if ghCapWnd <> 0 then

begin

// 装入状态回凋函数
retc := capSetCallbackOnStatus(ghCapWnd, LongInt(0));
if retc <> 0 then

begin

retc := capSetCallbackOnStatus(ghCapWnd, LongInt(@StatusCallbackProc));
if retc <> 0 then

begin

// 打开已经安装的摄像头
DriverIndex := 0;
repeat
DriverStarted := CapInitDriver( DriverIndex );
if NOT DriverStarted then
DriverIndex := DriverIndex + 1;
until (DriverStarted = TRUE) OR (DriverIndex >= MAXVIDDRIVERS);
// 维持现在的状态
if capGetDriverDescription( DriverIndex,
achDeviceName, 80,
achDeviceVersion, 100 ) then

begin

gCapVideoDriverName := string(achDeviceName);
end;

// 保存成文件 总是在打开的时候执行这个,并且retc总是为0
StrPCopy(achFileName, gCapVideoFileName);
retc := capFileSetCaptureFile(ghCapWnd, LongInt(@achFileName));
if retc = 0 then

begin

showmessage(gCapVideoDriverName+': Error in capFileSetCaptureFile');
end;

exit;
end;

end;

end;

Result := FALSE;
CapCloseDriver;
ghCapWnd := 0;
end;

 
我这儿有现成的控件,要的话请回复

-----------------
http://www.8421.org
 
好啊,谢谢,可以打包发到我的信箱
w984212@sina.com
 
http://www.8421.org/download/vcl/other_videocap23.zip
 
有没有DELPHI做的语音聊天的原码程序?
 
我也想要
 
顶部