首页 技术 正文
技术 2022年11月12日
0 收藏 899 点赞 4,399 浏览 2580 个字

FMX支持视频采集,具体见FMX.Media,提供了很类支持音频、视频的处理。

按帮助文档,用Note3做了测试,结果,效率太低,不可用。

具体可查询帮助Video Capturing一节,我就是按这个把代码复制过来做的测试.

一点进展:

对于这么低的效率,经与朋友讨论,应该是FMX完全自己处理的结果,如此说来,如果我们能调用Android内置的相机进行录像,然后取得录像文件,该问题就解决了。这样想来,Delphi XE6支持的拍照功能,就是按这个原理实现的,非常适用了!为此,XE6带做一个Standard Action,叫TTakePhotoFromCameraAction,非常快捷的支持拍照的开发,如果再提供一个TTakeVideoFromCameraAction该有多好!可惜了,现在还没有。

为了调用内置相机,朋友提醒我说,就是调用Android的Intent,怎么调用,还不会,那有没有人基于Android开发这样的控件呢?还真查到一组控件:DPF component suite for Android, 只可惜,目前还没有提供录像功能。

附测试的FMX代码:

unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts,
FMX.StdCtrls, FMX.Objects, FMX.ListBox,FMX.Media;
type
TForm2 = class(TForm)
Layout1: TLayout;
StartButton: TButton;
ComboBox1: TComboBox;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure StartButtonClick(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
VideoCamera: TVideoCaptureDevice;
procedure SampleBufferSync;
procedure SampleBufferReady(Sender: TObject; const ATime: TMediaTime);
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
{ TForm2 }
procedure TForm2.ComboBox1Change(Sender: TObject);
begin
VideoCamera := TVideoCaptureDevice
//(TCaptureDeviceManager.Current.GetDevicesByName(ComboBox1.Selected.Text));
(TCaptureDeviceManager.Current.Devices[]);
if (VideoCamera <> nil) then
begin
StartButton.Enabled := true;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
DeviceList: TCaptureDeviceList;
i: integer;
begin
DeviceList := TCaptureDeviceManager.Current.GetDevicesByMediaType
(TMediaType.Video);
for i := to DeviceList.Count - do
begin
ComboBox1.Items.Add(DeviceList[i].Name);//这里在note3上取不到Name.
end;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
if VideoCamera <> nil then
VideoCamera.StopCapture;
end;
procedure TForm2.SampleBufferReady(Sender: TObject; const ATime: TMediaTime);
begin
TThread.Synchronize(TThread.CurrentThread, SampleBufferSync);
//Resize the image so that the video is buffered in its original size
// Image1.Width:=Image1.Bitmap.Width;
// Image1.Height:=Image1.Bitmap.Height;
end;
procedure TForm2.SampleBufferSync;
begin
VideoCamera.SampleBufferToBitmap(Image1.Bitmap, true);
end;
procedure TForm2.StartButtonClick(Sender: TObject);
begin
if (VideoCamera <> nil) then
begin
if (VideoCamera.State = TCaptureDeviceState.Stopped) then
begin
VideoCamera.OnSampleBufferReady := SampleBufferReady;
VideoCamera.StartCapture;
StartButton.Text := 'Stop';
end
else
begin
VideoCamera.StopCapture;
StartButton.Text := 'Start';
end;
end
else
begin
Caption := 'Video capture devices not available.';
end;
end;
end.

http://blog.sina.com.cn/s/blog_44fa172f0101rg7p.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,300