tencent cloud

Creating Templates
Last updated:2026-01-12 18:52:31
Creating Templates
Last updated: 2026-01-12 18:52:31

Feature Description

Create a video screenshot template.

Authorization Description

When using with a sub-account, the ci:CreateMediaTemplate permission is required. For details, see Cloud Infinite action.

Activating a Service

Using this feature requires enabling Cloud Infinite in advance and binding a bucket. For details, see Bind Bucket.
Use this feature requires enabling Media Processing Service in advance via console or API. For details, see Enable Media Processing Service.

Use Limits

When using this API, please confirm the relevant restrictions first. For details, see Usage Limits.


Request

Request sample:

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 details, see Request Signature document.

Request header.

This API only uses common request headers. For details, see Common Request Headers documentation.

Request body.

The implementation of this request operation requires the following request body.
<Request>
<Tag>Snapshot</Tag>
<Name>TemplateName</Name>
<Snapshot>
<Mode>Interval</Mode>
<Width>1280</Width>
<Height>960</Height>
<Start>0</Start>
<TimeInterval>0.5</TimeInterval>
<Count>10</Count>
<SnapshotOutMode>OnlySprite</SnapshotOutMode>
<SpriteSnapshotConfig>
<Color>Aquamarine</Color>
<Columns>3</Columns>
<Lines>3</Lines>
</SpriteSnapshotConfig>
</Snapshot>
</Request>
The data are described as follows:
Node Name (Keyword)
Parent Node
Description
Type
Required or Not
Request
None.
Container for saving requests
Container
Yes
The specific data description for the
Request
Container type is as follows:
Node Name (Keyword)
Parent Node
Description
Type
Required or Not
Tag
Request
Template type: Snapshot
String
Yes
Name
Request
Template name, only supports Chinese, English, digits, _, -, and *, with length not exceeding 64.
String
Yes
Snapshot
Request
Screenshot parameter
Container
Yes
The specific data description for the
Snapshot
Container type is as follows:
Node Name (Keyword)
Parent Node
Description
Type
Default Value
Required or Not
Mode
Request.Snapshot
Snapshot mode
Value range: {Interval, Average, KeyFrame}
Interval indicates interval mode. Start, TimeInterval, and Count parameters take effect. When Count is set and TimeInterval is not set, it means capturing all frames, totaling Count images.
Average indicates average mode. Start and Count parameters take effect. It means capturing images at average intervals from Start to the end of the video, totaling Count images.
KeyFrame indicates key frame mode
String
Interval
No
Start
Request.Snapshot
Start Time
video duration
Unit: second
Support float format, execution accuracy accurate to milliseconds
String
0
No
TimeInterval
Request.Snapshot
Screenshot interval
(0 3600]
Unit: seconds
support float format, with execution accuracy accurate to milliseconds
String
None.
No
Count
Request.Snapshot
Number of screenshots, value range: (0, 10000]
String
None.
Yes
Width
Request.Snapshot
Wide
Value range: [128, 4096]
unit: px
If only Width is set, calculate Height based on the original aspect ratio of the video.
String
Original width of the video
No
Height
Request.Snapshot
High
Value range: [128, 4096]
unit: px
If only Height is set, calculate Width based on the original aspect ratio of the video.
String
Original height of the video
No
CIParam
Request.Snapshot
Screenshot image processing parameters, refer to Image Processing
String
None.
No
IsCheckCount
Request.Snapshot
Whether to force check the screenshot number. When using custom interval mode for screenshots and the video duration is insufficient to capture Count screenshots, it can be converted to average screenshot mode to capture Count screenshots.
String
false
No
IsCheckBlack
Request.Snapshot
Enable black screen check, parameter value: true, false
String
false
No
BlackLevel
Request.Snapshot
Screenshot black screen check parameter
Valid when IsCheckBlack=true
Value reference range [30, 100], indicates the proportion of black pixels, the smaller the value, the smaller the black proportion.
Start > 0, parameter setting is invalid, no filtering applied, black screen
Start = 0, parameter is valid, the start time for frame capture is the first non-black frame.
String
Null
No
PixelBlackThreshold
Request.Snapshot
Screenshot black screen check parameter
Valid when IsCheckBlack=true
Threshold for judging whether a pixel is a black pixel, value range: [0, 255]
String
Null
No
SnapshotOutMode
Request.Snapshot
Screenshot output mode parameter
OnlySnapshot: snapshot mode only
OnlySprite: Only output sprite mode
SnapshotAndSprite: Output screenshots and sprite mode
String
OnlySnapshot
No
SpriteSnapshotConfig
Request.Snapshot
Sprite sheet output configuration
Container
None.
No
The specific data description for the Container type Snapshot.SpriteSnapshotConfig is as follows:
Node Name (Keyword)
Parent Node
Description
Type
Default Value
Required or Not
CellWidth
Request.Snapshot.SpriteSnapshotConfig
Single image width
Value range: [8, 4096]
Unit: px
String
Screenshot width
No
CellHeight
Request.Snapshot.SpriteSnapshotConfig
Single image height
Value range: [8, 4096]
unit: px
String
Screenshot height
No
Padding
Request.Snapshot.SpriteSnapshotConfig
Sprite sheet inner padding size
Value range: [0, 1024]
Unit: px
String
0
No
Margin
Request.Snapshot.SpriteSnapshotConfig
Sprite sheet outer margin size
Value range: [0, 1024]
unit: px
String
0
No
Color
Request.Snapshot.SpriteSnapshotConfig
background color, supported colors are detailed in FFmpeg
String
None.
Yes
Columns
Request.Snapshot.SpriteSnapshotConfig
Number of columns in the sprite sheet, value range: [1, 10000]
String
None.
Yes
Lines
Request.Snapshot.SpriteSnapshotConfig
Number of rows in the sprite sheet, value range: [1, 10000]
String
None.
Yes
ScaleMethod
Request.Snapshot.SpriteSnapshotConfig
Sprite sheet scaling mode
DirectScale: specify width and height scaling
MaxWHScaleAndPad: specify maximum width and height scaling and padding
MaxWHScale: specify maximum width and height scaling
Actively set CellWidth and CellHeight, this parameter is valid only when
String
DirectScale
No

Response

Response Headers

This API only returns the public response header. For details, see Common Response Headers documentation.

Response Body

The response body is returned as application/xml. An example including the complete node data is shown below:
<Response>
<RequestId>NTk0MjdmODlfMjQ4OGY3XzYzYzhf****</RequestId>
<Template>
<Tag>Snapshot</Tag>
<Name>TemplateName</Name>
<TemplateId>t1f16e1dfbdc994105b31292d45710642a</TemplateId>
<BucketId>test-1234567890</BucketId>
<Category>Custom</Category>
<Snapshot>
<Mode>Interval</Mode>
<Width>1280</Width>
<Height>960</Height>
<Start>0</Start>
<TimeInterval>0.5</TimeInterval>
<Count>10</Count>
<SnapshotOutMode>OnlySprite</SnapshotOutMode>
<SpriteSnapshotConfig>
<Color>Aquamarine</Color>
<Columns>3</Columns>
<Lines>3</Lines>
</SpriteSnapshotConfig>
</Snapshot>
<CreateTime>2020-08-05T11:35:24+0800</CreateTime>
<UpdateTime>2020-08-31T16:15:20+0800</UpdateTime>
</Template>
</Response>
The data are as follows:
Node Name (Keyword)
Parent Node
Description
Type
Response
None.
Container for saving results
Container
Container node
Response
content:
Node Name (Keyword)
Parent Node
Description
Type
Template
Response
Container for saving results
Container
RequestId
Response
unique request ID
String
Container node
Template
content:
Node Name (Keyword)
Parent Node
Description
Type
Tag
Response
Template type: Snapshot
String
Name
Response
Template name
String
TemplateId
Response
template ID
String
UpdateTime
Response
Update time
String
CreateTime
Response
Creation time
String
Snapshot
Response
Detailed template parameters, same as Request.Snapshot
Container

Error Codes

This request returns common error responses and error codes. For more information, see Error Codes.

Examples

Request

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

<Request>
<Tag>Snapshot</Tag>
<Name>TemplateName</Name>
<Snapshot>
<Mode>Interval</Mode>
<Width>1280</Width>
<Height>960</Height>
<Start>0</Start>
<TimeInterval>0.5</TimeInterval>
<Count>10</Count>
<SnapshotOutMode>OnlySprite</SnapshotOutMode>
<SpriteSnapshotConfig>
<Color>Aquamarine</Color>
<Columns>3</Columns>
<Lines>3</Lines>
</SpriteSnapshotConfig>
</Snapshot>
</Request>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 100
Connection: keep-alive
Date: Thu, 14 Jul 2022 12:37:29 GMT
Server: tencent-ci
x-ci-request-id: NjMxMDJhYTNfMThhYTk0MGFfYmU1OV8zZjc=

<Response>
<RequestId>NjMxMDJhYTNfMThhYTk0MGFfYmU1OV8zZjc=</RequestId>
<Template>
<Tag>Snapshot</Tag>
<Name>TemplateName</Name>
<TemplateId>t1f16e1dfbdc994105b31292d45710642a</TemplateId>
<BucketId>test-1234567890</BucketId>
<Category>Custom</Category>
<Snapshot>
<Mode>Interval</Mode>
<Width>1280</Width>
<Height>960</Height>
<Start>0</Start>
<TimeInterval>0.5</TimeInterval>
<Count>10</Count>
<SnapshotOutMode>OnlySprite</SnapshotOutMode>
<SpriteSnapshotConfig>
<Color>Aquamarine</Color>
<Columns>3</Columns>
<Lines>3</Lines>
</SpriteSnapshotConfig>
</Snapshot>
<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