Creates a watermark template.

Usage notes

After you create a watermark template by calling this operation, you can specify the watermark template and watermark asset when you submit a transcoding job. This allows you to add watermark information to the output video.

QPS limit

You can call this API operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. For more information, see QPS limit.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AddWaterMarkTemplate

The operation that you want to perform. Set the value to AddWaterMarkTemplate.

Name String Yes example-watermark-****

The name of the watermark template. The value can contain letters and digits and can be up to 128 bytes in size.

Config String Yes {"Width":"10","Height":"30","Dx":"10","Dy":"5","ReferPos":"TopRight","Type":"Image","Timeline":{"Start":"0","Duration":"10"}}

The configuration of the watermark template. The value is a JSON object. For more information, see Watermark templates.

Note If you do not require a positive correlation between the size of text in the watermark and the resolution, you can enable adaptation for the watermark. To do so, add ['adaptive']=true to the text parameter of the watermark.

Response parameters

Parameter Type Example Description
WaterMarkTemplate Object

The details of the watermark template.

Type String Image

The type of the watermark. Valid values:

  • Image: an image watermark.
  • Text: a text watermark.
RatioRefer Object

The values of the Height, Width, Dx, and Dy parameters relative to the reference edges. If the values of the Height, Width, Dx, and Dy parameters are decimals between 0 and 1, the values are calculated by referring to the following edges in sequence:

  • Width: the width edge.
  • Height: the height edge.
  • Long: the long edge.
  • Short: the short edge.
Dx String 0.51

The horizontal offset of the watermark relative to the output video image. Default value: 0. The default value indicates no offset.

The value can be an integer or a decimal.

  • Integer: the vertical offset. This indicates the absolute position. Unit: pixel.
  • Decimal: the ratio of the horizontal offset to the width of the output video. The ratio varies based on the size of the video. Four decimal places are supported, such as 0.9999. More decimal places are discarded.
Width String 0.36

The width of the watermark image in the output video. The value can be an integer or a decimal.

  • Integer: the width of the watermark image. This indicates the absolute position. Unit: pixel.
  • Decimal: the ratio of the width of the watermark image to the width of the output video. The ratio varies based on the size of the video. Four decimal places are supported, such as 0.9999. More decimal places are discarded.
Height String 0.33

The height of the watermark image in the output video. The value can be an integer or a decimal.

  • Integer: the height of the watermark image. This indicates the absolute position. Unit: pixel.
  • Decimal: the ratio of the height of the watermark image to the height of the output video. The ratio varies based on the size of the video. Four decimal places are supported, such as 0.9999. More decimal places are discarded.
Dy String 0.28

The vertical offset of the watermark relative to the output video image. Default value: 0. The default value indicates no offset. The value can be an integer or a decimal.

  • Integer: the vertical offset. This indicates the absolute position. Unit: pixel.
  • Decimal: the ratio of the vertical offset to the height of the output video. The ratio varies based on the size of the video. Four decimal places are supported, such as 0.9999. More decimal places are discarded.
ReferPos String TopRight

The position of the watermark. Valid values:

  • TopRight: the upper-right corner.
  • TopLeft: the upper-left corner.
  • BottomRight: the lower-right corner.
  • BottomLeft: the lower-left corner.
State String Normal

The status of the watermark template. Valid values:

  • Normal: The watermark template is normal.
  • Deleted: The watermark template is deleted.
Dx String 10

The horizontal offset. Unit: pixel.

Width String 10

The width of the watermark image. Unit: pixel.

Height String 30

The height of the watermark image. Unit: pixel.

Timeline Object

The timeline of the watermark.

Start String 0

The beginning of the time range during which the watermark is displayed.

  • Unit: seconds.
  • Default value: 0.
Duration String ToEND

The display duration of the watermark. Default value: ToEND. The default value indicates that the watermark is displayed until the video ends.

Name String example-watermark-****

The name of the watermark template.

Dy String 5

The vertical offset. Unit: pixel.

Id String 3780bd69b2b74540bc7b1096f564****

The ID of the watermark template. We recommend that you keep this ID for subsequent operation calls.

RequestId String 54BB917F-DD35-4F32-BABA-E60E31B21W63

The ID of the request.

Examples

Sample requests

http(s)://mts.cn-shanghai.aliyuncs.com/?Action=AddWaterMarkTemplate
&Name=example-watermark-****
&Config={"Width":"10","Height":"30","Dx":"10","Dy":"5","ReferPos":"TopRight","Type":"Image","Timeline":{"Start":"0","Duration":"10"}}
&<Common request parameters>

Sample success response

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<AddWaterMarkTemplateResponse>
    <WaterMarkTemplate>
        <Type>Image</Type>
        <RatioRefer>
            <Dx>0.51</Dx>
            <Width>0.36</Width>
            <Height>0.33</Height>
            <Dy>0.28</Dy>
        </RatioRefer>
        <ReferPos>TopRight</ReferPos>
        <State>Normal</State>
        <Dx>10</Dx>
        <Width>10</Width>
        <Height>30</Height>
        <Timeline>
            <Start>0</Start>
            <Duration>ToEND</Duration>
        </Timeline>
        <Name>example-watermark-****</Name>
        <Dy>5</Dy>
        <Id>3780bd69b2b74540bc7b1096f564****</Id>
    </WaterMarkTemplate>
    <RequestId>54BB917F-DD35-4F32-BABA-E60E31B21W63</RequestId>
</AddWaterMarkTemplateResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "WaterMarkTemplate" : {
    "Type" : "Image",
    "RatioRefer" : {
      "Dx" : "0.51",
      "Width" : "0.36",
      "Height" : "0.33",
      "Dy" : "0.28"
    },
    "ReferPos" : "TopRight",
    "State" : "Normal",
    "Dx" : "10",
    "Width" : "10",
    "Height" : "30",
    "Timeline" : {
      "Start" : "0",
      "Duration" : "ToEND"
    },
    "Name" : "example-watermark-****",
    "Dy" : "5",
    "Id" : "3780bd69b2b74540bc7b1096f564****"
  },
  "RequestId" : "54BB917F-DD35-4F32-BABA-E60E31B21W63"
}

Error codes

For a list of error codes, visit the Error Center.