Screenshot taking is an offline task that takes screenshots of a video at specified times. VOD supports the following types of screenshots:
Common use cases include the following:
A screenshot template is a collection of screenshot parameters, including the output file format and image dimensions.
You can use a time point screenshot template to take a screenshot at a specific time point or generate a thumbnail.
Parameter | Description |
---|---|
Format | The screenshot format (only JPG is supported currently). |
Width | The screenshot width (px). Value range: 128-4096. |
Height | The screenshot height (px). Value range: 128-4096. |
FillType | The fill mode (FillType ) specifies how the source video is processed when its aspect ratio does not match the output aspect ratio. The following fill modes are supported: |
VOD provides preset time point screenshot templates for common parameter combinations. You can also create your own templates and manage them in the console. For details, see Template Settings.
You can use a sampled screenshot template to take screenshots at regular intervals.
Parameter | Description |
---|---|
Format | The screenshot format (only JPG is supported currently). |
Width | The screenshot width (px). Value range: 128-4096. |
Height | The screenshot height (px). Value range: 128-4096. |
SampleType | How sampling intervals are measured. Sampling intervals can be measured in two ways: Interval is set to 5 (%), 20 screenshots will be generated for a video. Interval is set to 10 (sec), the number of screenshots generated will depend on the video length. |
Interval | The sampling interval. SampleType ) is by percent, this parameter is a percent value. |
FillType | The fill mode (FillType ) specifies how the source video is processed when its aspect ratio does not match the output aspect ratio. The following fill modes are supported: |
VOD provides preset sampled screenshot templates for common parameter combinations. You can also create your own templates and manage them in the console. For details, see Template Settings.
You can use an image sprite screenshot template to generate image sprites.
Parameter | Description |
---|---|
Format | The format of the image sprite (only JPG is supported currently). |
Width | The width of the subimage in an image sprite. |
Height | The height of the subimage in an image sprite. |
Rows | The number of image rows in a sprite. |
Columns | The number of image columns in a sprite. |
SampleType | How sampling intervals are measured. Currently, only sampling by time is supported. |
Interval | The time interval for image sampling. |
Note:
- The result of multiplying
Width
xColumns
(i.e., sprite width) should be within the range of 128-4096.- The result of multiplying
Height
xRows
(i.e., sprite height) should be in the range of 128-4096.
VOD provides preset image sprite screenshot templates for common parameter combinations. You can also create your own templates and manage them in the console. For details, see Template Settings.
You can initiate a screenshot taking task by calling a server API, via the console, or by specifying the task when uploading videos. For details, see Task Initiation.
Specifically, you can initiate a screenshot task by doing one of the following:
MediaProcessTask.SnapshotByTimeOffsetTaskSet
.procedure
parameter to the task flow you created.procedure
in the upload signature to the task flow you created.After initiating a screenshot task, you can wait for the result notification asynchronously or perform a task query synchronously to get the task execution result. Below is an example of the notification received in normal callback mode after a screenshot task is initiated (the fields with null value are omitted):
{
"EventType":"ProcedureStateChanged",
"ProcedureStateChangeEvent":{
"TaskId":"1256768367-Procedure-2e1af2456351812be963e309cc133403t0",
"Status":"FINISH",
"FileId":"5285890784246869930",
"FileName":"Animal World",
"FileUrl":"http://1256768367.vod2.myqcloud.com/xxx/xxx/AtUCmy6gmIYA.mp4",
"MetaData":{
"AudioDuration":60,
"AudioStreamSet":[
{
"Bitrate":383854,
"Codec":"aac",
"SamplingRate":48000
}
],
"Bitrate":1021028,
"Container":"mov,mp4,m4a,3gp,3g2,mj2",
"Duration":60,
"Height":480,
"Rotate":0,
"Size":7700180,
"VideoDuration":60,
"VideoStreamSet":[
{
"Bitrate":637174,
"Codec":"h264",
"Fps":23,
"Height":480,
"Width":640
}
],
"Width":640
},
"MediaProcessResultSet":[
{
"Type":"SnapshotByTimeOffset",
"SnapshotByTimeOffsetTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"",
"Input":{
"Definition":10,
"Definition":[3, 6, 9]
},
"Output":{
"Definition":10,
"PicInfoSet":[
{
"TimeOffset":3,
"Url":"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx1.jpg"
},
{
"TimeOffset":6,
"Url":"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx2.jpg"
},
{
"TimeOffset":9,
"Url":"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx3.jpg"
}
]
}
}
},
{
"Type":"SampleSnapshot",
"SampleSnapshotTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"",
"Input":{
"Definition":10
},
"Output":{
"Definition":10,
"SampleType": "Percent",
"Interval": 10,
"WaterMarkDefinition": [],
"ImageUrlSet":[
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx1.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx2.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx3.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx4.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx5.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx6.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx7.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx8.jpg",
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx9.jpg"
]
}
}
},
{
"Type":"ImageSprites",
"ImageSpriteTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"",
"Input":{
"Definition":10
},
"Output":{
"Definition":10,
"Height":80,
"Width":142,
"TotalCount":1,
"ImageUrlSet":[
"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx1.jpg"
],
"WebVttUrl":"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx.vtt"
}
}
},
{
"Type":"CoverBySnapshot",
"CoverBySnapshotTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"",
"Input":{
"Definition":10,
"PositionType":"Time",
"PositionValue":0
},
"Output":{
"CoverUrl":"http://1256768367.vod2.myqcloud.com/xxx/xxx/xxx.jpg"
}
}
}
],
"TasksPriority":0,
"TasksNotifyMode":""
}
}
In the above callback, ProcedureStateChangeEvent.MediaProcessResultSet
contains four types of results, namely SnapshotByTimeOffset
, SampleSnapshot
, ImageSprites
, and CoverBySnapshot
, which represent a time point screenshot task, a sampled screenshot task, an image sprite screenshot task, and a thumbnail generation task respectively.
Was this page helpful?