delphi中如何捕获MediaPlayer播放的视频中的每一帧 ?


本文整理自网络,侵删。

 procedure TForm1.Button1Click(Sender: TObject);
var
Bitmap : TBitmap;
ImageRect : TRect;
ImageWidth : Integer;
ImageHeight : Integer;
Position : Integer;
i : Integer;
begin
if OpenDialog1.Execute then
begin
MediaPlayer1.FileName := OpenDialog1.FileName;
MediaPlayer1.Display := Form2;
MediaPlayer1.Open;

ImageRect := MediaPlayer1.DisplayRect;
ImageWidth := ImageRect.Right - ImageRect.Left + 1;
ImageHeight := ImageRect.Bottom - ImageRect.Top + 1;

Form2.FormStyle := fsStayOnTop;
Form2.ClientWidth := ImageWidth;
Form2.ClientHeight := ImageHeight;

MediaPlayer1.AutoRewind := False;
MediaPlayer1.Play;
MediaPlayer1.Position := 0;
MediaPlayer1.Frames := 1;

Bitmap := TBitmap.Create;
try
Bitmap.Width := ImageWidth;
Bitmap.Height := ImageHeight;

i := 0;
repeat
Position := MediaPlayer1.Position;
Bitmap.Canvas.CopyRect( ImageRect,Form2.Canvas, ImageRect);
Bitmap.SaveToFile( '.\' + IntToStr(i) + '.bmp');
MediaPlayer1.Step;
inc(i);
until MediaPlayer1.Position = Position;

finally
FreeAndNil(Bitmap);
end;

end;

end;

相关阅读 >>

windows7下使用Delphi7的方法

汇编基础知识

Delphi在网格cxgrid的左上角放置一个按钮

Delphi 获取listbox1多选的值

Delphi读写utf-8、unicode格式文本文件

Delphi 实现产品编号批量生成简单算法

Delphi之完美splash方案

Delphi 屏幕dpi计算

Delphi 更改消息对话框中的按钮标题

Delphi 自带大小写转换

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...