0
我使用VFW单元从WinAPI的JEDI包装。获取AVI文件时间
我写代码的目的是搜索用户驱动和检测名单中(注:决定是否某些文件是合法还是不超出了这个问题的范围)。我们做MP3,WMA和一些图形文件搜索。现在我们要检测非法电影。我想打开AVI文件,从中读取一些细节并关闭它。我有以下代码:
uses WFV; //from JEDI api wrappers
procedure TForm1.Button1Click(Sender: TObject);
var
lInfo : TAVIFILEINFOW;
lFile : IAVIFILE;
lFileType : string;
lLenMinutes : integer;
lFPS : integer;
begin
{init file}
AVIFileInit;
try
{Open file - note: since we search for warez this is perfely "warezy" file}
AVIFileOpen(lFile, 'e:\Sideways KLAXXON\Sideways KLAXXON.avi', OF_READ, nil);
try
{Get file info}
AVIFileInfoW(lFile, lInfo, sizeof(lInfo));
lFPS:=Round(lInfo.dwRate /lInfo.dwScale);
lLenMinutes := Round(lInfo.dwLength/lFPS/60);
lFileType := lInfo.szFileType;
{just for show: prepare some memo to see what we get}
memo1.Lines.Clear;
memo1.Lines.Add('File lenght [min]: ' + IntToStr(lLenMinutes));
memo1.Lines.Add('Width: ' + IntToStr(lInfo.dwWidth));
memo1.Lines.Add('Height: ' + IntToStr(lInfo.dwHeight));
memo1.Lines.Add('File type: ' + lFileType);
finally
{Closing the file}
AVIFileRelease (lFile);
Pointer(lFile) := nil;
end;
finally
{Releasing library}
AVIFileExit;
end;
end;
所以lLenMinutes是98的东西等于在影片约121分钟之久。这是一个巨大的差异。我究竟做错了什么? dwRate为100万和dwScale是40K,所以FPS是完全25. dwLength是147K MSDN says:“单位由dwRate和dwScale定义的”。
注:这是一个follow-up from this question,但是由于崩溃问题已经解决了,我关上了其他的问题,并搬到这里改进的内容。
请注意,WFV是相当过时了! – Ampere 2016-04-21 12:39:59