瞧一瞧,看一看,小弟有个有关问题,没有解决,请帮忙,已经困扰几天了。
瞧一瞧,看一看,小弟有个问题,没有解决,请各位高手帮忙,已经困扰几天了。。。。。
我做了一个录制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
------解决思路----------------------
AVIStreamSetFormat做了什么,自己去查代码
------解决思路----------------------
你强!我们玩多媒体都用ActiveX或MediaPlayer。。而你用API。。。。
我做了一个录制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
------解决思路----------------------
AVIStreamSetFormat做了什么,自己去查代码
------解决思路----------------------
你强!我们玩多媒体都用ActiveX或MediaPlayer。。而你用API。。。。