tencent cloud

All product documents
Cloud Infinite
DocumentationCloud Infinite
Creating Watermark Template
Last updated: 2024-02-29 09:57:29
Creating Watermark Template
Last updated: 2024-02-29 09:57:29

Feature Description

This API (CreateMediaTemplate) is used to create a watermark template.


Request

Sample request

POST /template HTTP/1.1
Host: <BucketName-APPID>.ci.<Region>.myqcloud.com
Date: <GMT Date>
Authorization: <Auth String>
Content-Length: <length>
Content-Type: application/xml

<body>
Note:
Authorization: Auth String (for more information, see Request Signature).
When this feature is used by a sub-account, relevant permissions must be granted. For more information, see Authorization Granularity.

Request headers

This API only uses common request headers. For more information, see Common Request Headers.

Request body

This request requires the following request body:
<Request>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Text</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Text>
<Text>Watermark content</Text>
<FontSize>30</FontSize>
<FontType></FontType>
<FontColor>0xRRGGBB</FontColor>
<Transparency>30</Transparency>
</Text>
</Watermark>
</Request>

<Request>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Image</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Image>
<Url>http://examplebucket-1250000000.ci.ap-beijing.myqcloud.com/shuiyin_2.png</Url>
<Mode>Proportion</Mode>
<Width>10</Width>
<Height></Height>
<Transparency>100</Transparency>
</Image>
</Watermark>
</Request>

The nodes are described as follows:
Node Name (Keyword)
Parent Node
Description
Type
Response
None
Response container
Container
Request has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Tag
Request
Template type: Watermark
String
Yes
Name
Request
Template name, which can contain letters, digits, underscores (_), hyphens (-), and asterisks (*).
String
Yes
Watermark
Request
Watermark information
Container
Yes
Watermark has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Default Value
Constraints
Type
Request.Watermark
Watermark type
String
Yes
None
Text: text watermark. Image: image watermark
Pos
Request.Watermark
Reference position
String
Yes
None
TopRight, TopLeft, BottomRight, BottomLeft, Left, Right, Top, Bottom, Center
LocMode
Request.Watermark
Offset mode
String
Yes
None
Relativity: proportionally. Absolute: fixed position.
Dx
Request.Watermark
Horizontal offset
String
Yes
None
1. Image watermark with Background being true: If locMode is Relativity, the unit is %, and the value range is [-300, 0]. If locMode is Absolute, the unit is px, and the value range is [-4096, 0].
2. Image watermark with Background being false: If locMode is Relativity, the unit is %, and the value range is [0, 100]. If locMode is Absolute, the unit is px, and the value range is [0, 4096].
3. Text watermark: If locMode is Relativity, the unit is %, and the value range is [0, 100]. If locMode is Absolute, the unit is px, and the value range is [0, 4096].
4. If Pos is Top, Bottom, or Center, this parameter will not take effect.
Dy
Request.Watermark
Vertical offset
String
Yes
None
1. Image watermark with Background being true: If locMode is Relativity, the unit is %, and the value range is [-300, 0]. If locMode is Absolute, the unit is px, and the value range is [-4096, 0].
2. Image watermark with Background being false: If locMode is Relativity, the unit is %, and the value range is [0, 100]. If locMode is Absolute, the unit is px, and the value range is [0, 4096].
3. Text watermark: If locMode is Relativity, the unit is %, and the value range is [0, 100]. If locMode is Absolute, the unit is px, and the value range is [0, 4096].
4. If Pos is Left, Right, or Center, this parameter will not take effect.
StartTime
Request.Watermark
Watermark start time
String
No
0
1. [0, video duration]
2. Unit: second
3. Supports the float format, accurate to the millisecond.
EndTime
Request.Watermark
Watermark end time
String
No
Video end time
1. [0, video duration]
2. 2. Unit: second
3. Supports the float format, accurate to the millisecond.
SlideConfig
Request.Watermark
Watermark sliding configuration. If this parameter is configured, the watermark offset setting will not take effect. This parameter is not supported for top speed codec transcoding/H.265 transcoding.
Container
No
None
None
Image
Request.Watermark
Image watermark node
Container
No
None
None
Text
Request.Watermark
Text watermark node
Container
No
None
None
SlideConfig has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Default Value
Constraints
SlideMode
Request.Watermark.SlideConfig
Sliding mode
String
Yes
None
Default: not enabled; ScrollFromLeft: slides from left to right. If ScrollFromLeft is set, the Watermark.Pos parameter will not take effect.
XSlideSpeed
Request.Watermark.SlideConfig
Horizontal sliding speed
String
Yes
None
Valid values: an integer between 0 and 10. Default value: 0.
YSlideSpeed
Request.Watermark.SlideConfig
Vertical sliding speed
String
Yes
None
Valid values: an integer between 0 and 10. Default value: 0.
Image has the following sub-nodes:

Image has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Default Value
Constraints
Url
Request.Watermark.Image
Watermark image address (which must be URL-encoded before being passed in).
String
Yes
None
Same as the watermark image address of the bucket.
Mode
Request.Watermark.Image
Dimension mode
String
Yes
None
1. Original: original size 2. Proportion: scaled proportionally 3. Fixed: fixed size
Width
Request.Watermark.Image
Width
String
No
None
1. If Mode is Original, the watermark image width cannot be set. 2. If Mode is Proportion, the unit is %, and the value range is [100, 300] for the background image and [1, 100] for the foreground image. Compared with the video width, the watermark image width cannot be greater than 4096 px. 3. If Mode is Fixed, the unit is px, and the value range is [8, 4096]. 4. If only Width is set, Height is calculated according to the original watermark image aspect ratio.
Height
Request.Watermark.Image
Height
String
No
None
1. If Mode is Original, the watermark image height cannot be set. 2. If Mode is Proportion, the unit is %, and the value range is [100, 300] for the background image and [1, 100] for the foreground image. Compared with the video height, the watermark image height cannot be greater than 4096 px. 3. If Mode is Fixed, the unit is px, and the value range is [8, 4096]. 4. If only Height is set, Width is calculated according to the original watermark image aspect ratio.
Transparency
Request.Watermark.Image
Transparency
String
Yes
None
Value range: [1, 100]. Unit: %
Background
Request.Watermark.Image
Whether it is a background image
String
No
false
Valid values: true, false
Watermark position description:


Text has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
Required
Default Value
Constraints
FontSize
Request.Watermark.Text
Font size
String
Yes
None
Value range: [5, 100]. Unit: px
FontType
Request.Watermark.Text
Font type
String
Yes
None
See the table below.
FontColor
Request.Watermark.Text
Font color
String
Yes
None
Format: 0xRRGGBB
Transparency
Request.Watermark.Text
Transparency
String
Yes
None
Value range: [1, 100]. Unit: %
Text
Request.Watermark.Text
Watermark content
String
Yes
None
The value can contain up to 64 letters, digits, underscores (_), hyphens (-), and asterisks (*).
FontType has the following sub-nodes:
Font Name
Supported Language
Description
simfang.ttf
Chinese/English
FangSong
simhei.ttf
Chinese/English
SimHei
simkai.ttf
Chinese/English
KaiTi
simsun.ttc
Chinese/English
SimSun
STHeiti-Light.ttc
Chinese/English
STHeiti-Light
STHeiti-Medium.ttc
Chinese/English
STHeiti-Medium
youyuan.TTF
Chinese/English
YouYuan
ariblk.ttf
English
None
arial.ttf
English
None
ahronbd.ttf
English
None
Helvetica.dfont
English
None
HelveticaNeue.dfont
English
None

Response

Response headers

This API only returns common response headers. For more information, see Common Response Headers.

Response body

The response body returns application/xml data. The following contains all the nodes:
<Response>
<Template>
<TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Text</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Text>
<Text>Watermark content</Text>
<FontSize>30</FontSize>
<FontType></FontType>
<FontColor>0xRRGGBB</FontColor>
<Transparency>30</Transparency>
</Text>
</Watermark>
<CreateTime>2020-08-05T11:35:24+0800</CreateTime>
<UpdateTime>2020-08-31T16:15:20+0800</UpdateTime>
</Template>
</Response>
The nodes are as described below:
Node Name (Keyword)
Parent Node
Description
Type
Response
None
Response container
Container
Response has the following sub-nodes:
Node Name (Keyword)
Parent Node
Description
Type
TemplateId
Response.Template
Template ID
String
Name
Response.Template
Template name
String
BucketId
Response.Template
Template bucket
String
Category
Response.Template
Template category: Custom or Official
String
Tag
Response.Template
Template type: VideoProcess
String
UpdateTime
Response.Template
Update time
String
CreateTime
Response.Template
Creation time
String
Watermark
Response.Template
Same as Request.Watermark in the request body.
Container

Error codes

There are no special error messages for this request. For common error messages, see Error Codes.

Samples

Request 1: Text watermark

POST /template HTTP/1.1
Authorization: q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0****&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=28e9a4986df11bed0255e97ff90500557e0e****
Host: examplebucket-1250000000.ci.ap-beijing.myqcloud.com
Content-Length: 1666
Content-Type: application/xml



<Request>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Text</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Text>
<Text>Watermark content</Text>
<FontSize>30</FontSize>
<FontType></FontType>
<FontColor>0xRRGGBB</FontColor>
<Transparency>30</Transparency>
</Text>
</Watermark>
</Request>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 100
Connection: keep-alive
Date: Thu, 15 Jun 2017 12:37:29 GMT
Server: tencent-ci
x-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****

<Response>
<Template>
<TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Text</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Text>
<Text>Watermark content</Text>
<FontSize>30</FontSize>
<FontType></FontType>
<FontColor>0xRRGGBB</FontColor>
<Transparency>30</Transparency>
</Text>
</Watermark>
<CreateTime>2020-08-05T11:35:24+0800</CreateTime>
<UpdateTime>2020-08-31T16:15:20+0800</UpdateTime>
</Template>
</Response>

Request 2: Image watermark

POST /template HTTP/1.1
Authorization: q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0****&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=28e9a4986df11bed0255e97ff90500557e0e****
Host: examplebucket-1250000000.ci.ap-beijing.myqcloud.com
Content-Length: 1666
Content-Type: application/xml

<Request>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Image</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Image>
<Url>http://examplebucket-1250000000.ci.ap-beijing.myqcloud.com/shuiyin_2.png</Url>
<Mode>Proportion</Mode>
<Width>10</Width>
<Height>10</Height>
<Transparency>30</Transparency>
</Image>
</Watermark>
</Request>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 100
Connection: keep-alive
Date: Thu, 15 Jun 2017 12:37:29 GMT
Server: tencent-ci
x-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****



<Response>
<Template>
<TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId>
<Tag>Watermark</Tag>
<Name>TemplateName</Name>
<Watermark>
<Type>Image</Type>
<LocMode>Absolute</LocMode>
<Dx>128</Dx>
<Dy>128</Dy>
<Pos>TopRight</Pos>
<StartTime>0</StartTime>
<EndTime>100.5</EndTime>
<Image>
<Url>http://examplebucket-1250000000.ci.ap-beijing.myqcloud.com/shuiyin_2.png</Url>
<Mode>Proportion</Mode>
<Width>10</Width>
<Height>10</Height>
<Transparency>30</Transparency>
</Image>
</Watermark>
<CreateTime>2020-08-05T11:35:24+0800</CreateTime>
<UpdateTime>2020-08-31T16:15:20+0800</UpdateTime>
</Template>
</Response>

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
中国香港
+852 800 906 020 (免费)
美国
+1 844 606 0804 (免费)
英国
+44 808 196 4551 (免费)
加拿大
+1 888 605 7930 (免费)
澳大利亚
+61 1300 986 386 (免费)
EdgeOne 热线
+852 300 80699
更多本地服务热线陆续新增中