All Products
Search
Document Center

ApsaraVideo Media Processing:Add visible watermarks to videos

Last Updated:Jan 22, 2024

You can add visible watermarks such as company logos or TV station logos to your videos to enhance brand visibility, protect copyrights, and boost product recognition. ApsaraVideo Media Processing (MPS) supports the following types of visible watermarks: image watermark, animated watermark, and text watermark. You can select a watermark type based on your business requirements. This topic describes the features of different types of visible watermarks and how to add visible watermarks to videos.

Overview

Scenarios

  • Short videos: You can protect the copyrights of your short videos by adding a watermark to the short videos before they are downloaded or shared. In most cases, you can add a product logo as an image watermark or a user ID as a text watermark.

  • Online videos: You can add a brand logo to online videos to claim copyright ownership. You can also add stickers to videos of entertainment programs to make the programs more interesting or increase ad visibility.

Features

Watermark type

Description

Related API request parameter

Supported in the MPS console

Image watermark

  • You can add up to four watermarks to a video and customize the start time, duration, position, and size of each watermark.

  • MPS allows you to add PNG images, animated PNG (APNG) images, MOV files, and GIF files as image watermarks.

  • You can use a watermark template to easily add image watermarks.

WaterMarks

Yes

Text watermark

  • You can add up to four watermarks to a video and customize the start time, duration, position, and size of each watermark.

  • You can customize the text content and font effects such as the font size, type, color, transparency, and border. For more information about supported fonts and colors, see Fonts and Color.

  • You cannot use a watermark template to add text watermarks.

WaterMarks

No

Add an image watermark in the MPS console

Note

The MPS console allows you to add only image watermarks. To add text watermarks, call the SubmitJobs API operation.

Add an image watermark when you submit a transcoding job

  1. Create a watermark template in the MPS console. For more information, see Manage watermark templates.

  2. Create a transcoding job in the MPS console. For more information, see Create a regular transcoding job or a workflow. Perform the following operations to use the watermark template:

    1. Turn on Watermark Templates.

    2. Select the watermark template that you create in Step 1 from the Watermark Templates drop-down list.

    3. Click Select next to the Watermark Image field. In the Select File dialog box, select a bucket from the Bucket drop-down list. Then, folders in the bucket are automatically displayed in the Path section. Select a file as the watermark.

      Note

      MPS allows you to add PNG images, APNG images, MOV files, and GIF files as image watermarks.

Add an image watermark when you use a workflow to submit a transcoding job

  1. Create a watermark template in the MPS console. For more information, see Manage watermark templates.

  2. Create a workflow in the MPS console. For more information, see Create a workflow. Perform the following operations to use the watermark template:

    Note

    You can add image watermarks when you use a transcoding or packaging workflow. In this example, a packaging workflow is used. The procedures for both workflows are the same.

    1. In the Topology section, click the image.png button on the Extract Video node.image.png

    2. Configure the Name and Transcoding Templates parameters based on your business requirements.

    3. Turn on Watermark.

    4. Select the watermark template that you create in Step 1 from the Watermark Templates drop-down list.

    5. Click Select next to the Watermark Image field. In the Select File dialog box, select a bucket from the Bucket drop-down list. Then, folders in the bucket are automatically displayed in the Path section. Select a file as the watermark.

      Note

      MPS allows you to add PNG images, APNG images, MOV files, and GIF files as image watermarks.

Add a watermark by calling the SubmitJobs API operation

Add an image watermark when you submit a transcoding job

When you call the SubmitJobs operation to submit a transcoding job, you can configure the parameters in the WaterMark object to add a watermark. You can use a watermark template to add image watermarks.

  • Type

    The type of the watermark. To add an image or animated watermark, set the Type parameter to Image.

  • InputFile

    The path of the Object Storage Service (OSS) object to be added as an image or animated watermark. MPS allows you to add PNG images, APNG images, MOV files, and GIF files as image watermarks.

  • WaterMarkTemplateId

    • The ID of the watermark template that is used to add an image watermark. The template contains all watermark settings but does not provide the actual image to be used as the watermark.

    • You can create a watermark template in the MPS console or by calling the AddWaterMarkTemplate API operation. For more information, see Manage watermark templates.

    Note

    If you leave the WaterMarkTemplateId parameter empty, the default watermark settings take effect. The parameter settings that you configure in the WaterMark object override those in a watermark template.

  • ReferPos, Dx, and Dy

    The ReferPos parameter specifies the reference position of the watermark on the output video. Valid values: TopLeft, TopRight, BottomLeft, and BottomRight.

    The Dx and Dy parameters specify the horizontal and vertical offsets of the watermark relative to the value of the ReferPos parameter. You can set the offsets to absolute pixel values or as percentages of the resolution of the output video.

  • Width and Height

    The width and height of the watermark. You can set the width and height to absolute pixel values or as percentages of the resolution of the output video.image.png

  • Timeline

    The start time and duration of the watermark.

Add a text watermark when you submit a transcoding job

When you call the SubmitJobs operation to submit a transcoding job, you can configure the parameters in the WaterMark object to add a watermark. You cannot use a watermark template to add text watermarks. You must configure the following watermark parameters in the API request:

  • Type

    The type of the watermark. To add a text watermark, set the Type parameter to Text.

  • TextWaterMark

    • Configure the Content parameter to specify the content of the text watermark. Emojis and line breaks are not supported in the text watermark. If the text is too long, it is truncated to fit within the display limit of the video image.

    • Configure the FontName, FontSize, FontColor, FontAlpha, BorderWidth, and BorderColor parameters of the text watermark.

    • Set the Top and Left parameters to absolute pixel values to specify the position of the text watermark relative to the upper-left corner of the output video.image.png

    • Example: {"Content":"5rWL6K+V5paH5a2X5******","FontName":"SimSun","FontSize":"16","Top":2,"Left":10}.

Sample code

When a video is transcoded to a 720P (1280×720) MP4 video, three watermarks are added to the output video. Some parameters of the watermarks are explicitly specified and override those in watermark templates.

  • Image watermark

    The upper-right corner of the output video is specified as the reference position. The watermark width is set to be 0.05 times the width of the output video. The watermark height is proportionally scaled based on the aspect ratio of the original watermark image.

  • Text watermark

    The content of the text watermark is Test text watermark. The text watermark is displayed at a position relative to the upper-left corner of the output video. The font is set to SimSun, font size to 16, color to red, and transparency to 50.

  • Animated watermark

    The lower-left corner of the output video is specified as the reference position. An MOV video is specified as the watermark. The watermark height is set to 240 pixels. The watermark width is proportionally scaled based on the aspect ratio of the watermark video.

For more information about the sample code in MPS SDKs for different programming languages, see the following topics: