Skip to content

TVideoGrabberFMX FireMonkey component

The TVideoGrabberFMX component (VidgrabFMX unit) displays the video of TVideoGrabber in a FireMonkey (FMX) form, with Delphi and C++Builder 10 Seattle and later, Windows 32-bit and 64-bit.

INSTALLATION

TVideoGrabberFMX is installed by the same package as TVideoGrabber (TVidGrab), on the "Datastead" page of the component palette: the IDE shows TVideoGrabber on the VCL forms and TVideoGrabberFMX on the FMX forms. C++Builder: include VidgrabFMX.hpp.

The TVidGrab package requires the FMX package of the IDE: applications built with runtime packages, VCL applications included, must also deploy fmxNNN.bpl. Applications statically linked are not affected.

USE

TVideoGrabberFMX wraps a TVideoGrabber instance, available through its VideoGrabber property (nil at design time): all the preview, recording, playback and reencoding properties, methods and events of TVideoGrabber are used through it, as with the VCL component.

Properties, methods and events of TVideoGrabberFMX:

  • DisplayMode: vdm_Fit (default, aspect ratio kept, borders filled with BackgroundColor), vdm_Stretch (stretched to the control), vdm_Center (original size, centered),
  • BackgroundColor: black by default,
  • HighQuality: high quality scaling, enabled by default,
  • OnFrameDisplayed: occurs in the main thread each time a new frame is displayed,
  • FrameWidth / FrameHeight: size of the last frame displayed,
  • VideoRect: rectangle of the video in the control (local coordinates),
  • LocalToVideo: converts a point of the control (e.g. the mouse position) into a pixel position of the video frame,
  • ClearDisplay: erases the last frame displayed (it stays displayed after the stop).

E.g.:

procedure TForm1.Button1Click(Sender: TObject);
begin
  VideoGrabberFMX1.DisplayMode := vdm_Fit;
  VideoGrabberFMX1.VideoGrabber.VideoSource := vs_VideoCaptureDevice;
  VideoGrabberFMX1.VideoGrabber.StartPreview;
end;

In the uses clause, list VidGrab before the FMX units: the names shared by the VCL and FMX (TBitmap, TCanvas...) then resolve to FMX, and the VCL types used by some TVideoGrabber events and methods are written qualified, e.g. Vcl.Graphics.TBitmap.

DUAL DISPLAY

The 2nd video window of TVideoGrabber (DualDisplay_Active = true, see Dual display) is supported as a separate floating window, with DualDisplay_Embedded = false (default value): it is drawn natively in its own window, as with the VCL component, and the other DualDisplay properties apply (e.g. DualDisplay_Monitor, DualDisplay_FullScreen).

E.g.:

VideoGrabberFMX1.VideoGrabber.DualDisplay_Active := True;
VideoGrabberFMX1.VideoGrabber.DualDisplay_Monitor := 1;
VideoGrabberFMX1.VideoGrabber.StartPreview;

DualDisplay_Embedded = true is not supported: the TVideoGrabber wrapped by TVideoGrabberFMX has no parent window, nothing is displayed and the 2nd video window decodes the video for nothing.

LIMITATIONS

TVideoGrabberFMX draws the video itself, without the native video window of TVideoGrabber:

  • the properties of the 1st native video window (Display properties) do not apply (embedded, full screen, stay on top, monitor, mouse, alpha blending, transparent color, location, pan-scan). Use the Visible property of the control instead of Display_Visible, and DisplayMode for the aspect ratio,
  • the logo displayed by the native video window while the video is stopped is not visible,
  • the audio VU-meters of TVideoGrabber require a native window: see TNativeChildWindow in the FmxDemoHelpers.pas unit of the MainDemoFMX project.

MAINDEMO FOR FIREMONKEY

The FireMonkey version of the MainDemo project (MainDemoFMX) is included in the package, with the same tabs as the VCL MainDemo; the video is displayed by a TVideoGrabberFMX control created at runtime, and the options of the native video window are disabled.