X
xiaohuan
Unregistered / Unconfirmed
GUEST, unregistred user!
我用USB摄像头捕捉视频,用vfw实现,现在想录像,部分代码如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
ghCapWnd:=CapCreateCaptureWindow
( PChar('KruwoSoft'),
WS_CHILD or WS_VISIBLE,
panel1.Left,
panel1.Top,
640,
480,
panel1.Handle,
0);
if ghCapWnd<>0 then
begin
CapDriverConnect(ghCapWnd, 0);
CapOverlay(ghCapWnd, 1);
end;
end;
//设置捕捉参数
procedure TForm1.Button2Click(Sender: TObject);
begin
CapParms.dwRequestMicroSecPerFrame:=66667;
//捕获速率
CapParms.fLimitEnabled := FALSE;
//时间限制
CapParms.fCaptureAudio := FALSE;
//是否捕捉音频
CapParms.fMCIControl := FALSE;
//
CapParms.fYield := TRUE;
CapParms.vKeyAbort := VK_ESCAPE;
CapParms.fAbortLeftMouse := FALSE;
CapParms.fAbortRightMouse := FALSE;
CapCaptureSetSetup(ghCapWnd,LongInt(@CapParms),sizeof(TCAPTUREPARMS));
end;
//录像
procedure TForm1.Button3Click(Sender: TObject);
begin
if ghCapWnd <> 0 then
begin
SaveDialog1.DefaultExt := 'mpeg';
SaveDialog1.Filter := 'AVI files (*.mpeg)|*.mpeg';
if SaveDialog1.Execute then
begin
capFileSetCaptureFile(ghCapWnd,longint(pchar(SaveDialog1.FileName)));
capcapturesequence(ghCapWnd);
end;
end;
end;
//停止录像
procedure TForm1.Button2Click(Sender: TObject);
begin
CapcaptureAbort(ghCapWnd);
end;
问题是,程序运行后我点Button1将设备和捕获窗口相连,然后点Button2设置捕获参数,再然后点button3开始录像,点button4停止,可是录出来的mpeg文件有问题不能播放
但是如果我不点botton2设置参数,直接录像的话就没有问题
请各位大侠帮忙看看问题出在哪儿,感激不尽!!!
procedure TForm1.Button1Click(Sender: TObject);
begin
ghCapWnd:=CapCreateCaptureWindow
( PChar('KruwoSoft'),
WS_CHILD or WS_VISIBLE,
panel1.Left,
panel1.Top,
640,
480,
panel1.Handle,
0);
if ghCapWnd<>0 then
begin
CapDriverConnect(ghCapWnd, 0);
CapOverlay(ghCapWnd, 1);
end;
end;
//设置捕捉参数
procedure TForm1.Button2Click(Sender: TObject);
begin
CapParms.dwRequestMicroSecPerFrame:=66667;
//捕获速率
CapParms.fLimitEnabled := FALSE;
//时间限制
CapParms.fCaptureAudio := FALSE;
//是否捕捉音频
CapParms.fMCIControl := FALSE;
//
CapParms.fYield := TRUE;
CapParms.vKeyAbort := VK_ESCAPE;
CapParms.fAbortLeftMouse := FALSE;
CapParms.fAbortRightMouse := FALSE;
CapCaptureSetSetup(ghCapWnd,LongInt(@CapParms),sizeof(TCAPTUREPARMS));
end;
//录像
procedure TForm1.Button3Click(Sender: TObject);
begin
if ghCapWnd <> 0 then
begin
SaveDialog1.DefaultExt := 'mpeg';
SaveDialog1.Filter := 'AVI files (*.mpeg)|*.mpeg';
if SaveDialog1.Execute then
begin
capFileSetCaptureFile(ghCapWnd,longint(pchar(SaveDialog1.FileName)));
capcapturesequence(ghCapWnd);
end;
end;
end;
//停止录像
procedure TForm1.Button2Click(Sender: TObject);
begin
CapcaptureAbort(ghCapWnd);
end;
问题是,程序运行后我点Button1将设备和捕获窗口相连,然后点Button2设置捕获参数,再然后点button3开始录像,点button4停止,可是录出来的mpeg文件有问题不能播放
但是如果我不点botton2设置参数,直接录像的话就没有问题
请各位大侠帮忙看看问题出在哪儿,感激不尽!!!