给个DirectShow9的你,Windows Media Player能播放的就能截,自己改一下吧,其实不怎么好用,因为得到的高宽不一定准确,指定的频不能精确到毫秒,只是能截Windows Media Player能播放文件。[
]
procedure TMainForm.GetBmp02;
var
dsMediaDet: IMediaDet;
dsMediaType: TAMMEDIATYPE;
dsMediaStreams, i, VideoStream: Integer;
p: int64;
begin
if MediaSeeking <> nil then
MediaSeeking.GetCurrentPosition(p)
else
p := 0;
p := Trunc(p / 10000000);
VideoStream := 0;
if FileExists(Media_FileName) = True then
if CoCreateInstance
(CLSID_MediaDet, nil, CLSCTX_INPROC, IID_IMediaDet, dsMediaDet) = S_OK then
if dsMediaDet.put_FileName(Media_FileName) = S_OK then
if dsMediaDet.get_OutputStreams(dsMediaStreams) = S_OK then
if dsMediaStreams > 0 then
begin
for i := 0 to dsMediaStreams - 1 do
if dsMediaDet.put_CurrentStream(i) = S_OK then
if dsMediaDet.get_StreamMediaType(dsMediaType) = S_OK then
if IsEqualGUID(dsMediaType.FormatType, FORMAT_VideoInfo) then
begin
VideoStream := i;
Break;
end;
if dsMediaDet.put_CurrentStream(VideoStream) = S_OK then
if dsMediaDet.get_StreamMediaType(dsMediaType) = S_OK then
begin
if IsEqualGUID(dsMediaType.FormatType, FORMAT_VideoInfo) then
begin
// dsMediaWidth :=
// Abs(TVIDEOINFOHEADER(dsMediaType.pbFormat^).bmiHeader.biWidth);
// dsMediaHeight :=
// Abs(TVIDEOINFOHEADER(dsMediaType.pbFormat^).bmiHeader.biHeight);
if dsMediaDet.WriteBitmapBits(p, Video_Width,
Video_Height, GetF) <> S_OK then
ShowMessage('Failed to Grab Image - Sorry');
end;
FreeMediaType(@dsMediaType);
// Sleep(2000);
end;
end;
dsMediaDet := nil;
end;