怎样向AVI中写入一个使用压缩格式的音频,如使用ADPCM压缩,我的代码为什么不好用!
Var
p:Array[0..1] of PAVICOMPRESSOPTIONS;
pp:Pointer;
Check1,Check2:Boolean;
bResult:LONG;
Wave:PWaveFormatEx;
begin
With PubCapture do
begin
Result:=false;
if CaptureAVI then
Exit;
if ghCapWnd<>0 then
begin
if SaveAVIFiled then
begin
//Result:=capFileSaveAs(ghCapWnd,PChar(SaveAsFileName));
Result:=capCaptureSequence(ghCapWnd);
end
else
begin
New(p[0]);
New(p[1]);
FillMemory(p[0], SizeOf(TAVICOMPRESSOPTIONS), 0);
FillMemory(p[1], SizeOf(TAVICOMPRESSOPTIONS), 0);
Try
AVIFileOpen(AVIHandle,PChar(SaveAsFileName),OF_CREATE or OF_SHARE_DENY_WRITE,nil);
GetWaveFormat(Wave,0,nil);
Try
with WaveStreamInfo do
begin
fccType := streamtypeAUDIO;
dwFlags := 0;
dwScale := Wave.nBlockAlign;
dwRate := Wave^.nSamplesPerSec*Wave^.nBlockAlign;
dwStart := 0;
dwLength := 1;
dwSuggestedBufferSize := 0;
dwQuality := DWORD(-1);
dwSampleSize:= Wave.nBlockAlign;
end;
AVIFileCreateStream(AVIHandle,WaveStream,WaveStreamInfo);
With p[1]^ do
begin
fccType:=WaveStreamInfo.fccType;
lpFormat:=Wave;
cbFormat:=SizeOf(TWaveFormatEx) + Wave^.cbSize;
end; Check1:=false;
Check2:=false;
if SUCCEEDED(AVIMakeCompressedStream(pCpWaveStream, WaveStream, p[1], nil)) then
begin
bResult:=AVIStreamSetFormat(pCpWaveStream, 0,
Wave, SizeOf(TWaveFormatEx) + Wave^.cbSize);
if SUCCEEDED(bResult) then
begin
Check2:=true;
end;
end;
end;
AVIStreamSetFormat过程调用失败!
Var
p:Array[0..1] of PAVICOMPRESSOPTIONS;
pp:Pointer;
Check1,Check2:Boolean;
bResult:LONG;
Wave:PWaveFormatEx;
begin
With PubCapture do
begin
Result:=false;
if CaptureAVI then
Exit;
if ghCapWnd<>0 then
begin
if SaveAVIFiled then
begin
//Result:=capFileSaveAs(ghCapWnd,PChar(SaveAsFileName));
Result:=capCaptureSequence(ghCapWnd);
end
else
begin
New(p[0]);
New(p[1]);
FillMemory(p[0], SizeOf(TAVICOMPRESSOPTIONS), 0);
FillMemory(p[1], SizeOf(TAVICOMPRESSOPTIONS), 0);
Try
AVIFileOpen(AVIHandle,PChar(SaveAsFileName),OF_CREATE or OF_SHARE_DENY_WRITE,nil);
GetWaveFormat(Wave,0,nil);
Try
with WaveStreamInfo do
begin
fccType := streamtypeAUDIO;
dwFlags := 0;
dwScale := Wave.nBlockAlign;
dwRate := Wave^.nSamplesPerSec*Wave^.nBlockAlign;
dwStart := 0;
dwLength := 1;
dwSuggestedBufferSize := 0;
dwQuality := DWORD(-1);
dwSampleSize:= Wave.nBlockAlign;
end;
AVIFileCreateStream(AVIHandle,WaveStream,WaveStreamInfo);
With p[1]^ do
begin
fccType:=WaveStreamInfo.fccType;
lpFormat:=Wave;
cbFormat:=SizeOf(TWaveFormatEx) + Wave^.cbSize;
end; Check1:=false;
Check2:=false;
if SUCCEEDED(AVIMakeCompressedStream(pCpWaveStream, WaveStream, p[1], nil)) then
begin
bResult:=AVIStreamSetFormat(pCpWaveStream, 0,
Wave, SizeOf(TWaveFormatEx) + Wave^.cbSize);
if SUCCEEDED(bResult) then
begin
Check2:=true;
end;
end;
end;
AVIStreamSetFormat过程调用失败!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货