The Dot Docs

DotVideo.pas

It is often interesting to be able to record a video of your running 3D application. DotVideo.pas gives you the tools to do so, in the form of a single, easy to use class called TDotVideoRecorder. The class has the following interface:

  TDotVideoRecorder = class
  public
    constructor Create;
    destructor Destroy; override;
    procedure StartCapture(const name: String; const window: TForm; const fps: Integer);
    procedure EndCapture;
    function Snap: Boolean;
    property OK: Boolean;
    property NumFrames: Integer;
  end;

To begin recording a video, you call StartCapture(). This method takes the filename of the video you want to save, the TForm from which you want to capture the video, and the framerate at which you want to capture (measured in frames per second). When called, it will pop up a dialog that allows you to choose a codec to use for saving your video.

You are now ready to capture frames to your video. To do so, you call the Snap() method, which captures a single image from the source form and appends it to your video stream. Note that the time elapsed between Snap() calls is completely ignored -- if you specified 20 fps when you called StartCapture(), your final video will be rendered at 20 images per second even if you called Snap() more or less often than 20 times per second. You can use a TTimer control or the Dot timing functions to make sure you Snap() at regular intervals.

When you're done recording your video, you can call EndCapture() to close your video stream. Your file is now ready to be played back.

TDotVideoRecorder has two more properties that are of interest. NumFrames, obviously, tells you how many frames have already been captured. OK is a boolean property that tells you whether or not the video recorder is correctly set up. You should not Snap() if things are not OK. This may happen for a number of reasons -- disk full, bad codecs, ... A file called "errors.txt" is generated when there is an error, and it will tell you which API call caused the problem.

The Delphi OpenGL Toolkit was written by Tom Nuydens.
See main page for disclaimer. For updates, visit Delphi3D.