ApsaraVideo VOD allows you to add watermarks to videos. You can add signature information such as enterprise logos, TV station logos, user IDs, and nicknames as watermarks to declare video copyright or promote brands. ApsaraVideo VOD supports static image watermarks, dynamic image watermarks, and text watermarks.
How the feature works
The video watermark feature is implemented based on transcoding. During video transcoding, you can add images or text to video streams as watermarks and generate new video files that have the watermarks.
Scenarios
Short video platforms
In most cases, the downloaded or shared short videos contain an image watermark (brand logo) and a text watermark (user ID) to declare video copyright.
Audio and video websites
In most cases, videos on audio and video websites use the brand logo as the watermark. You can also add stickers to videos of entertainment programs to create play tricks or improve advertisement exposure.
Watermark types
Type | Supported format | Description |
Image | | You can create watermark templates by using the ApsaraVideo VOD console to add watermarks in the PNG and GIF formats. You can create watermark templates by using the ApsaraVideo VOD API to add watermarks in the PNG, GIF, APNG, and MOV formats. If a file is used as a dynamic image watermark, the file name extension must be in lower case. File name extensions of files that are used as static image watermarks are not limited. The files that are used as watermarks and the video to which the watermarks are added must be stored in the same bucket. For example, videos that are stored in a bucket in the China (Shanghai) region can use only watermarks that are stored in the same bucket in the China (Shanghai) region. Videos cannot use watermarks that are stored in another region or bucket. For more information about storage buckets, see Manage storage buckets. You can specify the time when an image watermark is displayed on a video. An image watermark can be displayed throughout a video or within a specific time period.
|
Text | - | You can set font configurations such as the font type, size, color, transparency, and stroke. |
Billing rules
You are charged for transcoding when you use the video watermark feature. For more information, see Media transcoding.
Use the video watermark feature
Step 1: Create a watermark template
To simplify the process of watermark tasks, ApsaraVideo VOD allows you to create watermark templates in which you can configure watermark settings such as the position, size, text content, and color. Each watermark template has a unique ID.
Use the ApsaraVideo VOD console
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Configuration Management > Media Processing > Watermarks.
On the Watermarks page, click Create Watermark. On the page that appears, configure an image or text watermark template based on your business requirements.
Image watermark
Parameter | Description |
Watermark Type | Select Picture. |
Image | Upload an image.
Note Only PNG and GIF images are supported and the image size cannot exceed 20 MB. |
Watermark Name | The name of the watermark template.
Note The name can contain letters, digits, number signs (# ), and hyphens (- ). |
Size (Width × Height) | The size of the image watermark. For more information, see Watermark position and size. Format 1: positive integers. Unit: pixels. Valid values: [8,4096]. Format 2: percentages. Unit: %. Valid values: (0,100). The value can be accurate to two decimal places.
Note If you specify only the width or the height of the image watermark, the image is scaled based on the original aspect ratio. |
Location | The approximate position of the watermark relative to the output video image. Default value: Upper-right. For more information, see Watermark position and size. Valid values: Upper-left Lower-left Upper-right Lower-right
|
Horizontal Shift | The horizontal offset of the watermark on the output video image. For more information, see Watermark position and size. Format 1: positive integers. Unit: pixels. Valid values: [8,4096]. Format 2: percentages. Unit: %. Valid values: (0,100). The value can be accurate to two decimal places.
|
Vertical Shift | The vertical offset of the watermark on the output video image. For more information, see Watermark position and size. Format 1: positive integers. Unit: pixels. Valid values: [8,4096]. Format 2: percentages. Unit: %. Valid values: (0,100). The value can be accurate to two decimal places.
|
Timeline | The watermark timeline is used to control the start time and duration of an image watermark on a video. You can use multiple watermark configurations to control the dynamic display effect of an image watermark on a video.
Note This parameter is not supported for text watermarks. |
Preview Screen Size (Width × Height) | The width and height of the video. This allows you to preview the position and display effect of the watermark on the video. Unit: pixels. |
Text watermark
Parameter | Description |
Watermark Type | Select Text. |
Watermarking Content | The text content that you want to use as the watermark. |
Watermark Name | The name of the watermark template.
Note The name can contain letters, digits, number signs (# ), and hyphens (- ). |
Font | The font of the watermark. Valid values: SimSum WenQuanYi Zen Hei WenQuanYi Zen Hei Mono WenQuanYi Zen Hei Sharp Yuanti SC
|
Font Size | The font size. Unit: pixels. |
Transparency | The transparency of the text. A smaller value specifies more transparent text. Unit: pixels. The value can be accurate to two decimal places. Valid values: (0,1]. |
Font Color | The color of the text. |
Stroke Width | The width of the font stroke. Unit: pixels. Valid values: (0,4096]. |
Stroke Color | The color of the font stroke. |
Vertical Shift | The vertical offset of the watermark on the output video image. For more information, see Watermark position and size. The value must be a positive integer. Unit: pixels. Valid values: 8 to 4096. |
Horizontal Shift | The horizontal offset of the watermark on the output video image. For more information, see Watermark position and size. The value must be a positive integer. Unit: pixels. Valid values: 8 to 4096. |
Preview Image Size | The size of the video image. This allows you to preview the position and display effect of the watermark on the video. Unit: pixels. |
Click Save.
After the watermark template is created, you can view the template information such as the ID on the Watermarks page.
Use the ApsaraVideo VOD API
Call the AddWatermark operation to create a watermark template. After a watermark template is created, the template ID is returned.
Watermark position and size
Image watermark
You can use the ReferPos, Dx, Dy, Width, and Height parameters to specify the position and size of an image watermark on an output video.
API parameter | Parameter in the console | Description |
ReferPos | Location | The approximate position of the watermark relative to the output video image. Valid values: Upper-left Lower-left Upper-right Lower-right
|
Dx | Horizontal Shift | The horizontal offset of the watermark on the output video. You can specify this parameter in one of the following formats: Positive integer: Unit: pixels. Valid values: [8,4096]. Image proportion: a proportion to the video image. Valid values: (0,1).
|
Dy | Vertical Shift | The vertical offset of the watermark on the output video. You can specify this parameter in one of the following formats: Positive integer: Unit: pixels. Valid values: [8,4096]. Image proportion: a proportion to the video image. Valid values: (0,1).
|
Width | Width | The width of the watermark on the output video image. You can specify this parameter in one of the following formats: Positive integer: Unit: pixels. Valid values: [8,4096]. Image proportion: a proportion to the video image. Valid values: (0,1).
|
Height | Height | The height of the watermark on the output video image. You can specify this parameter in one of the following formats: Positive integer: Unit: pixels. Valid values: [8,4096]. Image proportion: a proportion to the video image. Valid values: (0,1).
|
Timeline | Timeline | The start time and duration of an image watermark on a video image. You can use multiple watermark configurations to manage the dynamic display effect of an image watermark on a video image. For more information, see Timeline: the configurations for a watermark timeline.
Important This parameter is not supported for text watermarks. |
Schematic diagram
To center a watermark on an output video, set the Dx and Dy parameters to 0.5. A value of 0.5 indicates that the horizontal or vertical offset of the watermark is 50% of the video width or height.
Text watermarks
You can specify the position of a text watermark on an output video only by setting the Top and Left parameters. The two parameters indicate the offset of the watermark relative to the upper-left corner of the output video image. The two parameters can be set only to positive integers that indicate the number of pixels. You cannot set them to decimal fractions that indicate a proportion to the video width or height.
API parameter | Parameter in the console | Description |
Top | Vertical Shift | The distance between the upper-left corner of the watermark and the upper side of the output video image. Unit: pixels. Valid values: 8 to 4096. |
Left | Horizontal Shift | The distance between the upper-left corner of the watermark and the left side of the output video image. Unit: pixels. Valid values: 8 to 4096. |
Schematic diagram
Calculation methods
The Dx, Dy, Width, and Height parameters of an image watermark can be calculated based on the positive integers or image proportions that you specify. The Top and Left parameters of a text watermark can be calculated based only on positive integers. The following content describes the calculation methods.
Positive integer: Unit: pixels. Valid values: [8,4096].
Important If the parameter settings of an image or text watermark are greater than the size of the output video image, the watermark may be partially displayed or not displayed at all.
For example, if the resolution of the output video is 640 × 360, and the ReferPos parameter is set to Upper-left, the Dx parameter is set to 4000, and the Dy parameter is set to 4000, the watermark is not displayed on the output video.
Image proportion: the proportion of the width and height of the image watermark to those of the output video. Valid values: (0, 1). The value is accurate to four decimal places.
Important If the resolutions of your output videos frequently change, we recommend that you set the position and size parameters of the watermarks to image proportion values.
Sample value: 0.9999. Example: Width/Video width = 0.1. Height/Video height = 0.06. Dx/Video width = 0.02. Dy/Video width = 0.03.
Default values
If you do not set the Width and Height parameters for a watermark, the width of the watermark is calculated based on the following formula: Watermark width = Output video width × 0.12. The height of the watermark proportionally scales based on the aspect ratio of the source watermark image.
If you specify one of the Width and Height parameters for a watermark, the value of the other parameter is calculated based on the specified parameter and the aspect ratio of the source watermark image. For example, if the Width parameter is set to 44, and the aspect ratio of the source image is 2:1, the value of the Height parameter is 22.
If you set both the Width and Height parameters, the width and height of the output watermark are set to the specified values.
The default values of the Dx and Dy parameters are both 0.
Step 2: Create a transcoding template group and add watermark templates
To create a transcoding task, you must specify a transcoding template group. You can add multiple watermark templates to a transcoding template.
Use the ApsaraVideo VOD console
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Configuration Management > Media Processing > Transcoding Template Groups.
Click Create Transcoding Template Group.
Specify the name of the transcoding template group.
Click Add Template in the Regular Transcoding Template or Video Packaging Template section, configure the transcoding parameters, and enable the watermark feature.
Definition: The Original definition is not supported.
Watermark Template: Select one or more watermark templates created in Step 1.
You can retain the default configurations of other parameters or configure other parameters based on your business requirements. For more information, see Configure regular transcoding templates.
Click Save.
After the transcoding template group is created, you can view the template group information such as the ID on the Transcoding Template Groups page.
Use the ApsaraVideo VOD API
Call the AddTranscodeTemplateGroup operation to create a transcoding template group. Specify the WatermarkIds
parameter in TranscodeTemplateList
to add the watermark template to the transcoding template group.
Step 3: (Optional) Create a workflow and specify a transcoding template group
You can add media processing tasks such as transcoding, review, snapshot capture tasks to a workflow based on a specific order. This way, you can use the workflow to process media files in the specified order. You can create workflows only by using the ApsaraVideo VOD console. For more information, see Workflows.
Use the ApsaraVideo VOD console
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Configuration Management > Media Processing > Workflows.
Click Add Workflow.
On the page that appears, specify a name for the workflow.
Add or modify the nodes in the workflow.
For example, perform the following operations to add a Transcode node to the workflow: Click + next to Start and select Transcode in the drop-down list. Click the modify icon next to Transcode. In the dialog box that appears, specify the Node Name field and select the transcoding template group for which a watermark template is added for Transcoding Template Group.
Click OK.
After a workflow is created, you can view workflow information such as the ID on the Workflows page.
Step 4: (Optional) Configure transcoding event notifications
We recommend that you configure event notifications before you submit a transcoding task. This way, you can obtain transcoding task information such as the status and results from the callback message. For more information about how to configure event notifications, see Configure callbacks.
The following content describes the events related to transcoding:
Step 5: Submit a transcoding task
You can trigger transcoding when you upload and process media files. To submit a transcoding task, you can use a transcoding template group or a workflow that contains a transcoding node.
Use the ApsaraVideo VOD console
Scenario 1: Automatically trigger transcoding during uploads
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video.
On the Upload Media page, click Add Media. In the dialog box that appears, specify the parameters such as Upload Method and Bucket, select Use Transcoding Template Group from the drop-down list, and then specify the transcoding template group that you created in Step 2. You can also select Use Workflow from the drop-down list and specify the workflow that you created in Step 3.
For more information about supported video formats and parameter descriptions, see Upload media files by using the ApsaraVideo VOD console.
Select the media files that you want to upload and click Upload.
After the media files are uploaded, the files are automatically transcoded based on the transcoding template group or workflow that you specified.
Scenario 2: Start transcoding for uploaded videos
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video.
On the Video and Audio page, find the media file that you want to transcode and click Media Processing in the Actions column.
In the dialog box that appears, select Use Transcoding Template Group from the drop-down list and specify the transcoding template group that you created in Step 2. You can also select Use Workflow from the drop-down list and specify the workflow that you created in Step 3.
Click Upload.
Use the ApsaraVideo VOD API
Scenario 1: Automatically add watermarks during uploads
When you call the CreateUploadVideo or UploadMediaByURL operation to upload audio and video files, set the TemplateGroupId
parameter to the ID of the transcoding template group that you created in Step 2 or the WorkflowId
parameter to the ID of the workflow that you created in Step 3. This way, ApsaraVideo VOD automatically processes the file based on the transcoding template group or workflow that you specified.
Scenario 2: Add watermarks to uploaded videos
Use a transcoding template group: Call the SubmitTranscodeJobs operation and set the TemplateGroupId
parameter to the ID of the transcoding template group that you created in Step 2.
Use a workflow: Call the SubmitWorkflowJob operation and set the WorkflowId
parameter to the ID of the workflow that you created in Step 3.
Step 6: View the results
Obtain results from the callback
If you have configured event notifications, you can obtain the transcoding results from the StreamTranscodeComplete or TranscodeComplete callback.
Query the results
Use the ApsaraVideo VOD console
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video.
On the Video and Audio page, view the Status of the video.
If the Status of the video is Normal, the transcoding is complete and the watermark is added.
Click Manage in the Actions column.
On the page that appears, click the Video URL tab. On the Video URL tab, you can view the transcoded streams of the video and obtain the playback URLs.
Use the ApsaraVideo VOD API
You can use the task ID to poll for the status and results of the transcoding task at regular intervals. The following content describes the API operations related to transcoding tasks:
Usage examples
This section provides usage examples on how to use ApsaraVideo VOD to configure multiple watermarks and call API operations to dynamically replace watermarks.
Declare short video copyright - dynamically change text watermarks
Scenario
When videos are being downloaded or shared from a short video platform, the videos usually contain the logo of the short video platform and the ID or nickname of the video creator.
Expected result
A text watermark and an image watermark are displayed on each video. Each user has a unique text watermark.
Implementation
Create two watermark templates and use the logo of the short video platform as an image watermark and the ID or nickname of the video creator as the text watermark. For more information, see Step 1: Create a watermark template.
Create a transcoding template group and add the two watermark templates to the transcoding template group. For more information, see Step 2: Create a transcoding template group and add watermark templates.
Call the SubmitTranscodeJobs operation to submit a transcoding task and specify the WatermarkId
and Content
parameters in OverrideParams
. This way, you can change the text content in the specified watermark template.
Example of OverrideParams
: {"Watermarks":[{"WatermarkId":"ID of the image watermark template"},{"WatermarkId":"ID of the text watermark template","Content":"Text content"}]}
You can configure the trigger condition for transcoding based on your business requirements. For example, you can configure to start transcoding during uploads and automatically use the ID or nickname of the video creator as the text watermark.
Promote video websites - dynamically change image watermarks
Scenario
A video website obtains the right to a movie or TV series and authorizes distribution to multiple video websites. In this case, the movie or TV series must contain the brand logo when being played on different websites.
Expected result
Different image watermarks are used when a video is played on different websites.
Implementation
Call the CreateUploadAttachedMedia operation to upload the brand logo that you want to use as the image watermark to ApsaraVideo VOD. For more information, see Upload media files by calling the ApsaraVideo VOD API.
Create an image watermark template and specify the brand logo of the video website as the image watermark. For more information, see Step 1: Create a watermark template.
Create a transcoding template group and add the watermark template to the transcoding template group. For more information, see Step 2: Create a transcoding template group and add watermark templates.
Call the SubmitTranscodeJobs operation to submit a transcoding task and specify the WatermarkId
and FileUrl
parameters in OverrideParams
. This way, you can change the image in the specified watermark template.
Example of OverrideParams
:{"Watermarks":{"WatermarkId":"ID of the mage watermark template","FileUrl":"URL of the image"}}
You can configure the trigger condition for transcoding based on your business requirements. For example, you can configure to start transcoding during uploads.
FAQ
What do I do if an error indicating that the image URL is invalid appears when I add an image watermark in the ApsaraVideo VOD console?
If you have configured an accelerated domain name in ApsaraVideo VOD, you must configure an SSL certificate for the domain name. For more information, see Enable HTTPS secure acceleration.
References
If you want to display the ID or nickname of the user in real time during video playback, use the marquee feature of ApsaraVideo Player SDK. This reduces copyright infringement. For more information, see Components.