Skip to main content

How can I add a text overlay?

SDK allows text overlay to be added to the video. You can set text, font parameters, color, position, and other properties.

Sample code

The sample code shows how to configure the text overlay and add it to the video.

// _videoEdit - VideoEditCoreX object

// create effect and set text
var textOverlay = new VisioForge.Core.Types.X.VideoEdit.TextOverlay("Hello world!");

// set start time and duration
textOverlay.Start = TimeSpan.FromMilliseconds(2000);
textOverlay.Duration = TimeSpan.FromMilliseconds(5000);

// set position
textOverlay.X = 50;
textOverlay.Y = 50;

// set font properties
textOverlay.FontFamily = "Arial";
textOverlay.FontSize = 40;
textOverlay.FontWidth = SkiaSharp.SKFontStyleWidth.Normal;
textOverlay.FontSlant = SkiaSharp.SKFontStyleSlant.Italic;
textOverlay.FontWeight = SkiaSharp.SKFontStyleWeight.Bold;

// set text color
textOverlay.Color = SkiaSharp.SKColors.Red;

// set background color
textOverlay.BackgroundColor = SkiaSharp.SKColors.Transparent;

_videoEdit.Video_TextOverlays.Add(textOverlay);

Set HAlign = TextOverlayHAlign.Custom and VAlign = TextOverlayVAlign.Custom to use custom position.

Types

SDK uses SkiaSharp library types to define font properties and colors.

Font enumeration

Use the Fonts property to get the list of available fonts. This property is OS-dependent and returns the list of fonts available on the current system.

var fonts = _videoEdit.Fonts;

Visit our GitHub page to get more code samples.