function TForm1.My_CutMpegFile(SourceFile,DestFile:String;StartTime,TimeLength:integer):Boolean;
const //MyHeardSize=44+2352*32;//DWORD;文件头75308字节
MyTimeFramSize=2352*75;//每秒钟176400字节
var
MyHeardSize:integer;
MyMpegFile:TFileStream;
MyMemFile:TMemoryStream;
begin
Result:=True;
MyHeardSize:=GetPacketHead(SourceFile);
MyMpegFile:=TFileStream.Create(SourceFile,fmOpenRead or fmShareDenyNone);
MyMemFile:=TMemoryStream.Create;
try
try
MyMemFile.CopyFrom(MyMpegFile,MyHeardSize);
{ if StartTime=1 then
MyMpegFile.Seek(MyHeardSize,soFrombegin
ning)
else
}
MyMpegFile.Seek(MyHeardSize+MyTimeFramSize*StartTime,soFrombegin
ning);
MyMemFile.CopyFrom(MyMpegFile,MyTimeFramSize*TimeLength);
MyMemFile.SaveToFile(DestFile);
finally
MyMemFile.Free;
MyMpegFile.Free;
end;
except
Result:=False;
end;
end;