请各位高手帮忙,已经困扰几天了。。。。。

9807146wang 2012-08-02 01:43:30
我做了一个录制AVI文件并保存的程序,为什么执行到设置流格式,也就是这句会出错AVIStreamSetFormat。

有时要执行好几次才可以录制保存成功。请各位高手帮忙。
var
status:HVSTATUS;
ppBuf:Array[1..1] of pChar; //保存图像的缓冲区列表
pPointer:longWord; //指向缓冲区列表的指针
wVer:WORD;
hr:HRESULT;
bRVal:boolean;

strhdr:PAVISTREAMINFOA ; //AVI文件信息
opts:PAVICOMPRESSOPTIONS ;
FileName:String;
begin

bRVal := TRUE;
status := STATUS_OK;
hr := S_OK;

wVer := HIWORD(VideoForWindowsVersion());
if ( (wVer >= 266)) then // oops, we are too old, blow out of here // if 2
begin
AVIFileInit();

FileName:='D:\'+formatdatetime('yyyymmddhhnnss',now)+'.avi';
// 创建AVI文件 // returned file pointer // file name // mode to open file with
hr := AVIFileOpen(m_pFile, Pchar(FileName), OF_WRITE or OF_CREATE,nil); // use handler determined

if (hr <> AVIERR_OK) then // if 3
begin
bRVal := FALSE;
end
else
begin
new(strhdr);
strhdr.fccType := streamtypeVIDEO;// stream type
strhdr.fccHandler := 0; // 808810089
strhdr.dwScale := 1;
strhdr.dwRate := 15; // rate fps
strhdr.dwSuggestedBufferSize := HV_Width * HV_Height * 3;
SetRect(strhdr.rcFrame, 0, 0, HV_Width, HV_Height);// rectangle for stream
// And create the stream; // file pointer // returned stream pointer
hr := AVIFileCreateStream(m_pFile,m_ps,strhdr); // stream header
if (hr <> AVIERR_OK) then // if 4
begin
bRVal := FALSE;
end
else
begin
new(opts);
(* opts.fccType := StreamTypeVIDEO;
opts.fccHandler := 808810089; // 0
opts.dwKeyFrameEvery :=0;
opts.dwQuality :=8500;
opts.dwBytesPerSecond :=0;
opts.dwFlags :=8;
opts.lpFormat :=nil;
opts.cbFormat :=0;
opts.cbParms :=48;
opts.dwInterleaveEvery := 0;
*)
if (not AVISaveOptions(FrmMain.Handle, 0, 1, m_ps, opts)) then // if 5
begin
bRVal := FALSE;
end
else
begin
hr := AVIMakeCompressedStream(m_psCompressed, m_ps, opts, nil);
if (hr <> AVIERR_OK) then // if 6
begin
bRVal := FALSE;
end
else // format size
begin // stream format
try
hr := AVIStreamSetFormat(m_psCompressed,0,m_pBmpInfo,sizeof(BITMAPINFOHEADER));

if (hr <> AVIERR_OK) then
bRVal := FALSE;
except
end;
end; // end if 6
end; // end if 5
end; // end if 4
end; // end if 3
end; // end if 2
...全文
113 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
9807146wang 2012-08-08
  • 打赏
  • 举报
回复
没有知道吗????
haitao 2012-08-02
  • 打赏
  • 举报
回复
视频操作不懂

这种试几次又可以的报错,就加try except end再试

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧