怎么转换视频格式,比如AVI转成3GP或者MPEG(300分)

  • 主题发起人 主题发起人 超然
  • 开始时间 开始时间

超然

Unregistered / Unconfirmed
GUEST, unregistred user!
我想作个视频转换的工具,但是不知道怎么下手,请问那里又想关介绍,教程什么的
 
查找3gp和mpeg的编码和解码函数或开源的代码,研究透了就可以实现视频转换了.
 
问题是这种软件N多,但是这些码和解码函数或开源的代码找不到啊
 
我也想找找,但是不知道呀,听说有个什么控件可以,我晕,。。。。
 
uses VfW ;
{$R *.dfm}
function GrabAVIFrame(avifn: string;
iFrameNumber: Integer;
ToFileName: TFileName): Boolean;
var
Error: Integer;
pFile: PAVIFile;
AVIStream: PAVIStream;
gapgf: PGETFRAME;
lpbi: PBITMAPINFOHEADER;
bits: PChar;
hBmp: HBITMAP;
AviInfo: TAVIFILEINFOW;
sError: string;
TmpBmp: TBitmap;
DC_Handle: HDC;
begin

Result := False;
// Initialize the AVIFile library.
AVIFileInit;

// The AVIFileOpen function opens an AVI file
Error := AVIFileOpen(pFile, PChar(avifn), 0, nil);
if Error <> 0 then

begin

AVIFileExit;
case Error of
AVIERR_BADFORMAT: sError := 'The file couldn''t be read';
AVIERR_MEMORY: sError := 'The file could not be opened because of insufficient memory.';
AVIERR_FILEREAD: sError := 'A disk error occurred while reading the file.';
AVIERR_FILEOPEN: sError := 'A disk error occurred while opening the file.';
end;

ShowMessage(sError);
Exit;
end;


// AVIFileInfo obtains information about an AVI file
if AVIFileInfo(pFile, @AVIINFO, SizeOf(AVIINFO)) <> AVIERR_OK then

begin

// Clean up and exit
AVIFileRelease(pFile);
AVIFileExit;
Exit;
end;


// Show some information about the AVI
Form1.Memo1.Lines.Add('AVI Width : ' + IntToStr(AVIINFO.dwWidth));
Form1.Memo1.Lines.Add('AVI Height : ' + IntToStr(AVIINFO.dwHeight));
Form1.Memo1.Lines.Add('AVI Length : ' + IntToStr(AVIINFO.dwLength));

// Open a Stream from the file
Error := AVIFileGetStream(pFile, AVIStream, streamtypeVIDEO, 0);
if Error <> AVIERR_OK then

begin

// Clean up and exit
AVIFileRelease(pFile);
AVIFileExit;
Exit;
end;


// Prepares to decompress video frames
gapgf := AVIStreamGetFrameOpen(AVIStream, nil);
if gapgf = nil then

begin

AVIStreamRelease(AVIStream);
AVIFileRelease(pFile);
AVIFileExit;
Exit;
end;


// Read current Frame
// AVIStreamGetFrame Returns the address of a decompressed video frame
lpbi := AVIStreamGetFrame(gapgf, iFrameNumber);
if lpbi = nil then

begin

AVIStreamGetFrameClose(gapgf);
AVIStreamRelease(AVIStream);
AVIFileRelease(pFile);
AVIFileExit;
Exit;
end;


// Show number of frames:
Form1.Memo1.Lines.Add(Format('Framstart: %d FrameEnd: %d',
[AVIStreamStart(AVIStream), AVIStreamEnd(AVIStream)]));

TmpBmp := TBitmap.Create;
try
TmpBmp.Height := lpbi.biHeight;
TmpBmp.Width := lpbi.biWidth;
bits := Pointer(Integer(lpbi) + SizeOf(TBITMAPINFOHEADER));

DC_Handle := CreateDC('Display', nil, nil, nil);
try
hBmp := CreateDIBitmap(DC_Handle, // handle of device context
lpbi^, // address of bitmap size and format data
CBM_INIT, // initialization flag
bits, // address of initialization data
PBITMAPINFO(lpbi)^, // address of bitmap color-format data
DIB_RGB_COLORS);
// color-data usage
finally
DeleteDC(DC_Handle);
end;


TmpBmp.Handle := hBmp;
AVIStreamGetFrameClose(gapgf);
AVIStreamRelease(AVIStream);
AVIFileRelease(pfile);
AVIFileExit;
try
TmpBmp.SaveToFile(ToFileName);
Result := True;
except
end;

finally
TmpBmp.Free;
end;

end;
 
先感谢楼上的,但是问题出来了,哪有VfW?
 
终于找到VfW.PAS文件了,但是下面三个类型的定义在那个文件里的,找不到啊
pFile: PAVIFile;
AVIStream: PAVIStream;
gapgf: PGETFRAME;
 
后退
顶部