Skip to main content

Record watermark

Overview

In Composite Recording mode, you can add watermarks to the video, such as a logo, timestamp, or text, for copyright protection, promotion, or recording.

The On-Premise Recording SDK supports three types of watermarks:

  • Text watermarks: Use text as the watermark. You can specify the font and font size.
  • Timestamp watermarks: Use a dynamic timestamp that shows the current time of the recording server (such as "2019:06:18 14:30:35") as the watermark. You can specify the font size of the timestamp.
  • Image watermark: Use a PNG image as the watermark. The image is displayed at a fixed position on the video.

The On-Premise Recording SDK v3.0 and later support watermarks.

Configure watermarks

Text watermarks

Set the literalWms parameter to add a text watermark. You can specify multiple LiteraWatermarkConfig objects in the literalWms parameter.

A LiteraWatermarkConfig object contains the following parameters:

  • wmLitera adds the text in the string format.
  • fontFilePath specifies the path of the font file. Supported font file formats: TTF and OTF. If not specified, the default font, NotoSansMonoCJKsc-Regular, is used.
  • fontSize specifies the font size of the text. If not specified, the default font size is 10 (10 x 15 points at 144 dpi).
  • offsetX, offsetY, wmWidth, and wmHeight specify the position and size of the watermark rectangle.
  • Supports up to 10 text watermarks.
  • Supports only UTF-8 encoding.
  • The supported characters depend on the font. The default font is NotoSansMonoCJKsc-Regular. See the font introduction.
  • There is no limit on the string length. How the text is displayed on the watermark rectangle depends on the font size and the size of the watermark rectangle. The part of the text that exceeds the area of the rectangle will not be displayed.
  • Supports word wrap and line breaks.
  • The font color is either black or white and automatically changes according to the video background: If the background is dark, the font color is white; and if the background is bright, the font color is black.

Timestamp watermarks

Set the timestampWms parameter to add a timestamp watermark. You can specify a TimestampWatermarkConfig object in the timestampWms parameter.

A TimestampWatermarkConfig object contains the following parameters:

  • fontSize specifies the font size of the timestamp. If not specified, the default font size is 10 (10 x 15 points at 144 dpi).
  • offsetX, offsetY, wmWidth, and wmHeight specify the position and size of the watermark rectangle.
  • Supports only one timestamp watermark.
  • The dynamic timestamp shows the current time of the recording server, such as "2019:06:18 14:30:35".
  • The timestamp color is either black or white and automatically changes according to the video background: If the background is dark, the color is white; and if the background is bright, the color is black.

Image watermarks

Set the imageWms parameter to add an image watermark. You can specify multiple ImageWatermarkConfig objects in the imageWms parameter.

An ImageWatermarkConfig object contains the following parameters:

  • imagePath specifies the path of the image.
  • offsetX, offsetY, wmWidth, and wmHeight specify the position and size of the watermark rectangle].
  • Supports up to four image watermarks.
  • Supports only local PNG images.
  • The resolution of the image should not exceed 480p.
  • If the image is smaller than the watermark rectangle, the SDK centers the image; if the image is larger than the watermark rectangle, the SDK resizes and centers the image in the watermark rectangle.

Specify the size and position of a watermark rectangle

No matter what type of watermark you want to add, you must set the offsetX, offsetY, wmWidth, and wmHeight parameters to specify the horizontal position, vertical position, width, and height of the watermark rectangle.

As shown in the figure above, we set the upper left-corner of the video canvas as the origin. The offsetX and offsetY parameters define the position of the watermark rectangle on the canvas, representing the horizontal and vertical distances between the upper-left corner of the rectangle and the origin respectively. The wmWidth and wmHeight parameters define the width and height of the rectangle. The offsetX, offsetY, wmWidth, and wmHeight parameters are absolute values in pixels. The default value is 0.

Add watermarks

You can add watermarks to the recorded video in the following ways:

  • Set the literalWms, timestampWms, or imageWms parameters when calling the setVideoMixingLayout method.
  • Set the literaWms, timestampWms, or imgWms parameters when calling the updateWatermarkConfigs method.

Update and delete watermarks

You can call the setVideoMixingLayout or updateWatermarkConfigs methods to update the configuration of the watermarks and also to delete them.

For example, if you have added an image watermark and a text watermark and you want to delete the text watermark, you can delete the configuration of the text watermark, pass in the configuration of the original image watermark, and then call the setVideoMixingLayout or updateWatermarkConfigs method.

Note that if you want to delete all the watermarks that you have added, you must call the updateWatermarkConfigs method and set the literaWms, timestampWms, and imgWms parameters as null. If you call the setVideoMixingLayout method and do not set the literalWms, timestampWms, or imageWms parameters, the On-Premise Recording SDK will not change the watermarks.

Code snippets

The following Java code snippets show how to add an image watermark, a timestamp watermark, and a text watermark by calling the setVideoMixingLayout method.

/*
* RecordingSDKInstance is the instance of the RecordingSDK class.
*/
Common ei = new Common();
Common.VideoMixingLayout layout = ei.new VideoMixingLayout();
layout.timestampWms = new TimestampWatermarkConfig[1];
layout.timestampWms[0] = ei.new TimestampWatermarkConfig();
layout.timestampWms[0].fontSize = 10;
layout.timestampWms[0].offsetX = 10;
layout.timestampWms[0].offsetY = 110;
layout.timestampWms[0].wmWidth = 200;
layout.timestampWms[0].wmHeight = 100;
layout.literalWms = new LiteraWatermarkConfig[1];
layout.literalWms[0] = ei.new LiteraWatermarkConfig();
layout.literalWms[0].wmLitera = "hello world";
layout.literalWms[0].fontSize = 10;
layout.literalWms[0].offsetX = 10;
layout.literalWms[0].offsetY = 10;
layout.literalWms[0].wmWidth = 300;
layout.literalWms[0].wmHeight = 100;
layout.imageWms = new ImageWatermarkConfig[1];
layout.imageWms[0] = ei.new ImageWatermarkConfig();
layout.imageWms[0].imagePath = "path-to-test.png";
layout.imageWms[0].offsetX = 10;
layout.imageWms[0].offsetY = 220;
layout.imageWms[0].wmWidth = 400;
layout.imageWms[0].wmHeight = 400;
RecordingSDKInstance.setVideoMixingLayout(layout);
Copy
vundefined