Page 1 of 1
Adding text to video recording
Posted: Wed Jul 29, 2020 9:28 pm
by wernerh
Hi,
I am using the TRVCamRecorder to record videos and just wondering if it's possible to add text to a video, like a caption or timestamp?
Re: Adding text to video recording
Posted: Thu Jul 30, 2020 10:08 am
by Sergey Tkachenko
Use TRVCamera.OnGetImage event.
The code below adds a timestamp to the bottom right corner:
Code: Select all
procedure TForm1.RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
var
bmp: TBitmap;
S: String;
Sz: TSize;
begin
bmp := img.GetBitmap;
with bmp.Canvas do
begin
Lock;
try
Brush.Style := bsClear;
Font.PixelsPerInch := 96;
Font.Name := 'Tahoma';
Font.Color := clWhite;
Font.Size := 8;
S := TimeToStr(Now);
Sz := TextExtent(S);
TextOut(bmp.Width - Sz.cx - 2, bmp.Height - Sz.cy - 2, S);
finally
Unlock;
end;
end;
img.UpdateData;
end;
Note that this event may be called in a thread context.
If you need to add a static image, like a logo, the recommended way is to prepare it in TRVMBitmap object, and use OnGetImage to draw as img.Draw(X, Y, MyLogoBitmap); You do not need to call img.UpdateData after using this method (if MyLogoBitmap is TRVMBitmap)