给你找到一段程序,应该可以:function GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;
说明:
avifilename: avi文件名
index: 要取的桢号
bmp: 存放返回图象, 如果为nil则自动建立一个bitmap. 如果存在则按bmp
定义的大小存放stretch后的图象.
返回值: true 成功, false 失败.代码:uses windows, graphics;interfaceconst
streamtypeAUDIO : longint = $73647561;
streamtypeVIDEO : longint = $73646976;type
TAVIStream = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
Name : array [0..64] of char;
end; PAVIStream = ^TAVIStream; PAVIFile = pointer; TAVIFileInfo = record
dwMaxBytesPerSec : longint;
dwFlags : longint;
dwCaps : longint;
dwStreams : longint;
dwSuggestedBufferSize : longint; dwWidth : longint;
dwHeight : longint; dwScale : longint;
dwRate : longint;
dwLength : longint; dwEditCount : longint; szFileType : array[0..63] of char;
end; PAVIFileInfo = ^TAVIFileInfo; TAVIStreamInfo = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
szName : array[0..63] of char;
end; PAVIStreamInfo = ^TAVIStreamInfo;function AVIFileOpen(avifile : pointer; filename : pchar; mode : integer;
CLSID : pointer) : integer; stdcall; external 'avifil32.dll' index 16;function AVIFileRelease(avifile : pointer) : longint; stdcall; external 'avifil32.dll' index 20;function AVIFileGetStream(avifile : pointer; avistream : PAVIStream;
streamtype : longint; lParam : longint) : integer; stdcall; external 'avifil32.dll' index 11;function AVIStreamGetFrameOpen(avistream : PAVIStream; bitmapwanted : pointer) : pointer; stdcall; external 'avifil32.dll' index 42;procedure AVIStreamGetFrameClose(pget : pointer); stdcall; external 'avifil32.dll' index 41;function AVIStreamGetFrame(getframe : pointer; position : longint) : pointer; stdcall; external 'avifil32.dll' index 40;procedure AVIStreamRelease(avistream : PAVIStream); stdcall; external 'avifil32.dll' index 53;function AVIStreamInfo(pstream : PAVIStream; psi : PAVISTREAMINFO; lsize : longint) : integer; stdcall; external 'avifil32.dll' index 44;function GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;implementationfunction GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;
var
FAviFile : Pointer;
FVideoStream : Pointer;
FGetFrame : Pointer;
info : TAVIStreamInfo;
FFrameWidth, FFrameHeight : Integer;
FStartFrame, FStopFrame : Integer;
image : PBitmapInfoHeader;
imagestart : Integer;
begin
result := false;
if (AVIFileOpen(@favifile, pchar(AviFileName), 0, nil) <> 0) then
exit; if (AVIFileGetStream(favifile, @fvideostream, streamtypeVIDEO, 0) <> 0) then
begin
AVIFileRelease(favifile);
exit;
end; AVIStreamInfo(fvideostream, @info, sizeof(info));
with info do
begin
fFrameWidth := rcframe.right - rcframe.left;
fFrameHeight := rcframe.bottom - rcframe.top;
fStartFrame := dwStart;
fStopFrame := dwLength - 1;
end; if (index <fstartframe) or (index > fstopframe) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; fgetframe := AVIStreamGetFrameOpen(fvideostream, nil);
if (fgetframe = nil) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; image := AVIStreamGetFrame(fgetframe, Index);
if assigned(image) then
begin
if not assigned(bmp) then
begin
bmp := tbitmap.create;
bmp.width := fframewidth;
bmp.height := fframeheight;
end
else if bmp.empty then
begin
bmp.width := fframewidth;
bmp.height := fframeheight;
end;
imagestart := image^.biSize + image^.biClrUsed * 4;
StretchDIBits(bmp.canvas.handle, 0, 0, bmp.width, bmp.height,
0, 0, fframewidth, fframeheight,
pchar(image) + imagestart,
TBitmapInfo(image^), 0, SRCCOPY);
result := true;
end; AVIStreamGetFrameClose(fgetframe);
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
end;end.
说明:
avifilename: avi文件名
index: 要取的桢号
bmp: 存放返回图象, 如果为nil则自动建立一个bitmap. 如果存在则按bmp
定义的大小存放stretch后的图象.
返回值: true 成功, false 失败.代码:uses windows, graphics;interfaceconst
streamtypeAUDIO : longint = $73647561;
streamtypeVIDEO : longint = $73646976;type
TAVIStream = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
Name : array [0..64] of char;
end; PAVIStream = ^TAVIStream; PAVIFile = pointer; TAVIFileInfo = record
dwMaxBytesPerSec : longint;
dwFlags : longint;
dwCaps : longint;
dwStreams : longint;
dwSuggestedBufferSize : longint; dwWidth : longint;
dwHeight : longint; dwScale : longint;
dwRate : longint;
dwLength : longint; dwEditCount : longint; szFileType : array[0..63] of char;
end; PAVIFileInfo = ^TAVIFileInfo; TAVIStreamInfo = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
szName : array[0..63] of char;
end; PAVIStreamInfo = ^TAVIStreamInfo;function AVIFileOpen(avifile : pointer; filename : pchar; mode : integer;
CLSID : pointer) : integer; stdcall; external 'avifil32.dll' index 16;function AVIFileRelease(avifile : pointer) : longint; stdcall; external 'avifil32.dll' index 20;function AVIFileGetStream(avifile : pointer; avistream : PAVIStream;
streamtype : longint; lParam : longint) : integer; stdcall; external 'avifil32.dll' index 11;function AVIStreamGetFrameOpen(avistream : PAVIStream; bitmapwanted : pointer) : pointer; stdcall; external 'avifil32.dll' index 42;procedure AVIStreamGetFrameClose(pget : pointer); stdcall; external 'avifil32.dll' index 41;function AVIStreamGetFrame(getframe : pointer; position : longint) : pointer; stdcall; external 'avifil32.dll' index 40;procedure AVIStreamRelease(avistream : PAVIStream); stdcall; external 'avifil32.dll' index 53;function AVIStreamInfo(pstream : PAVIStream; psi : PAVISTREAMINFO; lsize : longint) : integer; stdcall; external 'avifil32.dll' index 44;function GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;implementationfunction GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;
var
FAviFile : Pointer;
FVideoStream : Pointer;
FGetFrame : Pointer;
info : TAVIStreamInfo;
FFrameWidth, FFrameHeight : Integer;
FStartFrame, FStopFrame : Integer;
image : PBitmapInfoHeader;
imagestart : Integer;
begin
result := false;
if (AVIFileOpen(@favifile, pchar(AviFileName), 0, nil) <> 0) then
exit; if (AVIFileGetStream(favifile, @fvideostream, streamtypeVIDEO, 0) <> 0) then
begin
AVIFileRelease(favifile);
exit;
end; AVIStreamInfo(fvideostream, @info, sizeof(info));
with info do
begin
fFrameWidth := rcframe.right - rcframe.left;
fFrameHeight := rcframe.bottom - rcframe.top;
fStartFrame := dwStart;
fStopFrame := dwLength - 1;
end; if (index <fstartframe) or (index > fstopframe) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; fgetframe := AVIStreamGetFrameOpen(fvideostream, nil);
if (fgetframe = nil) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; image := AVIStreamGetFrame(fgetframe, Index);
if assigned(image) then
begin
if not assigned(bmp) then
begin
bmp := tbitmap.create;
bmp.width := fframewidth;
bmp.height := fframeheight;
end
else if bmp.empty then
begin
bmp.width := fframewidth;
bmp.height := fframeheight;
end;
imagestart := image^.biSize + image^.biClrUsed * 4;
StretchDIBits(bmp.canvas.handle, 0, 0, bmp.width, bmp.height,
0, 0, fframewidth, fframeheight,
pchar(image) + imagestart,
TBitmapInfo(image^), 0, SRCCOPY);
result := true;
end; AVIStreamGetFrameClose(fgetframe);
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
end;end.
说明:
avifilename: avi文件名
index: 要取的桢号
bmp: 存放返回图象, 如果为nil则自动建立一个bitmap. 如果存在则按bmp
定义的大小存放stretch后的图象.
返回值: true 成功, false 失败.代码:uses windows, graphics;interfaceconst
streamtypeAUDIO : longint = $73647561;
streamtypeVIDEO : longint = $73646976;type
TAVIStream = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
Name : array [0..64] of char;
end; PAVIStream = ^TAVIStream; PAVIFile = pointer; TAVIFileInfo = record
dwMaxBytesPerSec : longint;
dwFlags : longint;
dwCaps : longint;
dwStreams : longint;
dwSuggestedBufferSize : longint; dwWidth : longint;
dwHeight : longint; dwScale : longint;
dwRate : longint;
dwLength : longint; dwEditCount : longint; szFileType : array[0..63] of char;
end; PAVIFileInfo = ^TAVIFileInfo; TAVIStreamInfo = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
szName : array[0..63] of char;
end; PAVIStreamInfo = ^TAVIStreamInfo;function AVIFileOpen(avifile : pointer; filename : pchar; mode : integer;
CLSID : pointer) : integer; stdcall; external 'avifil32.dll' index 16;function AVIFileRelease(avifile : pointer) : longint; stdcall; external 'avifil32.dll' index 20;function AVIFileGetStream(avifile : pointer; avistream : PAVIStream;
streamtype : longint; lParam : longint) : integer; stdcall; external 'avifil32.dll' index 11;function AVIStreamGetFrameOpen(avistream : PAVIStream; bitmapwanted : pointer) : pointer; stdcall; external 'avifil32.dll' index 42;procedure AVIStreamGetFrameClose(pget : pointer); stdcall; external 'avifil32.dll' index 41;function AVIStreamGetFrame(getframe : pointer; position : longint) : pointer; stdcall; external 'avifil32.dll' index 40;procedure AVIStreamRelease(avistream : PAVIStream); stdcall; external 'avifil32.dll' index 53;function AVIStreamInfo(pstream : PAVIStream; psi : PAVISTREAMINFO; lsize : longint) : integer; stdcall; external 'avifil32.dll' index 44;function GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;implementationfunction GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;
var
FAviFile : Pointer;
FVideoStream : Pointer;
FGetFrame : Pointer;
info : TAVIStreamInfo;
FFrameWidth, FFrameHeight : Integer;
FStartFrame, FStopFrame : Integer;
image : PBitmapInfoHeader;
imagestart : Integer;
begin
result := false;
if (AVIFileOpen(@favifile, pchar(AviFileName), 0, nil) <> 0) then
exit; if (AVIFileGetStream(favifile, @fvideostream, streamtypeVIDEO, 0) <> 0) then
begin
AVIFileRelease(favifile);
exit;
end; AVIStreamInfo(fvideostream, @info, sizeof(info));
with info do
begin
fFrameWidth := rcframe.right - rcframe.left;
fFrameHeight := rcframe.bottom - rcframe.top;
fStartFrame := dwStart;
fStopFrame := dwLength - 1;
end; if (index <fstartframe) or (index > fstopframe) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; fgetframe := AVIStreamGetFrameOpen(fvideostream, nil);
if (fgetframe = nil) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; image := AVIStreamGetFrame(fgetframe, Index);
if assigned(image) then
begin
if not assigned(bmp) then
begin
bmp := tbitmap.create;
bmp.width := fframewidth;
bmp.height := fframeheight;
end
else if bmp.empty then
begin
bmp.width := fframewidth;
bmp.height := fframeheight;
end;
imagestart := image^.biSize + image^.biClrUsed * 4;
StretchDIBits(bmp.canvas.handle, 0, 0, bmp.width, bmp.height,
0, 0, fframewidth, fframeheight,
pchar(image) + imagestart,
TBitmapInfo(image^), 0, SRCCOPY);
result := true;
end; AVIStreamGetFrameClose(fgetframe);
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
end;end.
说明:
avifilename: avi文件名
index: 要取的桢号
bmp: 存放返回图象, 如果为nil则自动建立一个bitmap. 如果存在则按bmp
定义的大小存放stretch后的图象.
返回值: true 成功, false 失败.代码:uses windows, graphics;interfaceconst
streamtypeAUDIO : longint = $73647561;
streamtypeVIDEO : longint = $73646976;type
TAVIStream = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
Name : array [0..64] of char;
end; PAVIStream = ^TAVIStream; PAVIFile = pointer; TAVIFileInfo = record
dwMaxBytesPerSec : longint;
dwFlags : longint;
dwCaps : longint;
dwStreams : longint;
dwSuggestedBufferSize : longint; dwWidth : longint;
dwHeight : longint; dwScale : longint;
dwRate : longint;
dwLength : longint; dwEditCount : longint; szFileType : array[0..63] of char;
end; PAVIFileInfo = ^TAVIFileInfo; TAVIStreamInfo = record
fccType : longint;
fccHandler : longint;
dwFlags : longint;
dwCaps : longint;
wPriority : word;
wLanguage : word;
dwScale : longint;
dwRate : longint;
dwStart : longint;
dwLength : longint;
dwInitialFrames : longint;
dwSuggestedBufferSize : longint;
dwQuality : longint;
dwSampleSize : longint;
rcFrame : TRect;
dwEditCount : longint;
dwFormatChangeCount : longint;
szName : array[0..63] of char;
end; PAVIStreamInfo = ^TAVIStreamInfo;function AVIFileOpen(avifile : pointer; filename : pchar; mode : integer;
CLSID : pointer) : integer; stdcall; external 'avifil32.dll' index 16;function AVIFileRelease(avifile : pointer) : longint; stdcall; external 'avifil32.dll' index 20;function AVIFileGetStream(avifile : pointer; avistream : PAVIStream;
streamtype : longint; lParam : longint) : integer; stdcall; external 'avifil32.dll' index 11;function AVIStreamGetFrameOpen(avistream : PAVIStream; bitmapwanted : pointer) : pointer; stdcall; external 'avifil32.dll' index 42;procedure AVIStreamGetFrameClose(pget : pointer); stdcall; external 'avifil32.dll' index 41;function AVIStreamGetFrame(getframe : pointer; position : longint) : pointer; stdcall; external 'avifil32.dll' index 40;procedure AVIStreamRelease(avistream : PAVIStream); stdcall; external 'avifil32.dll' index 53;function AVIStreamInfo(pstream : PAVIStream; psi : PAVISTREAMINFO; lsize : longint) : integer; stdcall; external 'avifil32.dll' index 44;function GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;implementationfunction GetAviFrame(AviFilename : String; Index: Integer; var bmp: TBitmap): boolean;
var
FAviFile : Pointer;
FVideoStream : Pointer;
FGetFrame : Pointer;
info : TAVIStreamInfo;
FFrameWidth, FFrameHeight : Integer;
FStartFrame, FStopFrame : Integer;
image : PBitmapInfoHeader;
imagestart : Integer;
begin
result := false;
if (AVIFileOpen(@favifile, pchar(AviFileName), 0, nil) <> 0) then
exit; if (AVIFileGetStream(favifile, @fvideostream, streamtypeVIDEO, 0) <> 0) then
begin
AVIFileRelease(favifile);
exit;
end; AVIStreamInfo(fvideostream, @info, sizeof(info));
with info do
begin
fFrameWidth := rcframe.right - rcframe.left;
fFrameHeight := rcframe.bottom - rcframe.top;
fStartFrame := dwStart;
fStopFrame := dwLength - 1;
end; if (index <fstartframe) or (index > fstopframe) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; fgetframe := AVIStreamGetFrameOpen(fvideostream, nil);
if (fgetframe = nil) then
begin
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
exit;
end; image := AVIStreamGetFrame(fgetframe, Index);
if assigned(image) then
begin
if not assigned(bmp) then
begin
bmp := tbitmap.create;
bmp.width := fframewidth;
bmp.height := fframeheight;
end
else if bmp.empty then
begin
bmp.width := fframewidth;
bmp.height := fframeheight;
end;
imagestart := image^.biSize + image^.biClrUsed * 4;
StretchDIBits(bmp.canvas.handle, 0, 0, bmp.width, bmp.height,
0, 0, fframewidth, fframeheight,
pchar(image) + imagestart,
TBitmapInfo(image^), 0, SRCCOPY);
result := true;
end; AVIStreamGetFrameClose(fgetframe);
AVIStreamRelease(fvideostream);
AVIFileRelease(favifile);
end;
end.