The SnapshotComplete event notifies you when video snapshots are complete. This topic covers the notification content and sample callbacks.
Event type
SnapshotComplete
Event description
ApsaraVideo VOD generates the SnapshotComplete event after snapshots are taken for a video.
-
Snapshotting and transcoding are performed concurrently.
-
If the snapshots are thumbnail snapshots and the CoverUrl parameter is not specified, one of the thumbnail snapshots is used as the video thumbnail. For more information about thumbnail snapshots, see Video snapshots.
-
Call the GetVideoInfo operation to obtain the URLs of the video thumbnail and CoverSnapshot snapshots.
-
Call the ListSnapshots operation to obtain the URLs of the latest snapshots for a specific video.
If URL signing is enabled, you must generate your own auth_key to access snapshot URLs. Otherwise, an HTTP 403 error is returned. For more information about URL signing, see URL signing.
Event notification content
|
Parameter name |
Type |
Required |
Description |
|
EventTime |
String |
Yes |
The time when the event is generated, in the yyyy-MM-ddTHH:mm:ssZ format (UTC). |
|
EventType |
String |
Yes |
The event type. The value is SnapshotComplete. |
|
VideoId |
String |
Yes |
The ID of the video. |
|
Status |
String |
Yes |
The status of the video snapshot.
|
|
SubType |
String |
No |
The subtype of the snapshot. The value is SpecifiedTime. Note
A SpecifiedTime value indicates that the snapshot is taken by calling the SubmitSnapshotJob operation. |
|
ErrorCode |
String |
No |
The error code. Returned only when the snapshot job fails. |
|
ErrorMessage |
String |
No |
The error message. Returned only when the snapshot job fails. |
|
CoverUrl |
String |
No |
The thumbnail URL. Not returned if the snapshot job fails. |
|
SnapshotInfos |
SnapshotInfo[] |
No |
The snapshot details. Not returned if the snapshot job fails. For more information, see SnapshotInfos data below. |
|
Extend |
String |
No |
A user-defined pass-through parameter returned in callbacks. For more information, see the "UserData" section in Request parameters. |
Snapshot data
|
Parameter name |
Type |
Required |
Description |
|
Status |
String |
Yes |
The status of the video snapshot job.
|
|
SnapshotType |
String |
Yes |
The snapshot type.
For more information, see Video snapshots. |
|
SnapshotCount |
Long |
Yes |
The total number of snapshots. |
|
SnapshotFormat |
String |
Yes |
The naming format of snapshots. Use this value with the OSS storage URL or CDN domain name to construct snapshot URLs. Note
If your domain name changes frequently, use this parameter to generate snapshot URLs dynamically. |
|
SnapshotRegular |
String |
Yes |
The rule for generating snapshot URLs. We recommend that you use the SnapshotRegular value to generate snapshot URLs. For details, see the following section. Note
If a domain name exists, the rule for a CDN URL is returned. Otherwise, the rule for an OSS URL is returned. Rules for HTTPS URLs are not supported. |
|
JobId |
String |
Yes |
The ID of the snapshot job. |
For newly uploaded videos, snapshots are stored in the same OSS storage address as the source video. For more information, see Manage storage buckets.
Generation of snapshot URLs
You can generate snapshot URLs in two ways:
-
Generate a snapshot URL based on the SnapshotFormat value
-
Rule: http(s)://{CDN domain name or OSS storage URL}/SnapshotFormat.
-
Description: {SnapshotCount} is the serial number of each snapshot, padded with leading zeros to five digits.
-
Examples:
-
If the serial number of the first snapshot is 00001, the snapshot URL is:
http://example.com/2327a6ec24b44844b3a5e2c1b691****/covers/990f3820db2948b5b4a13d65d9a4****-00001.jpg. -
If the serial number of the second snapshot is 00002, the snapshot URL is:
http://example.com/2327a6ec24b44844b3a5e2c1b691****/covers/990f3820db2948b5b4a13d65d9a4****-00002.jpg.And so on.
-
-
-
Generate a snapshot URL based on the SnapshotRegular value
-
Rule: SnapshotRegular is a complete URL rule.
-
Replace {SnapshotCount} with the snapshot serial number, the same way as for SnapshotFormat.
-
Sample callbacks
Description:
-
For an HTTP callback, this example shows the HTTP POST request body.
-
For an MNS callback, this example shows the message body.
{
"EventType": "SnapshotComplete",
"EventTime": "2018-07-31T10:07:31Z",
"CoverUrl": "http://sample/covers/990f3820db2948b5b4a13d65d9a4****-00002.jpg",
"Extend":"test data",
"SnapshotInfos": [
{
"Status": "success",
"SnapshotType": "CoverSnapshot",
"SnapshotCount": 2,
"SnapshotFormat": "2327a6ec24b44844b3a5e2c1b691****/covers/990f3820db2948b5b4a13d65d9a4****-{SnapshotCount}.jpg",
"SnapshotRegular": "http://sample/covers/990f3820db2948b5b4a13d65d9a4****-{SnapshotCount}.jpg",
"JobId": "ee16d4bbf3f7*****e094bcb8cf8ddde"
},
{
"Status": "success",
"SnapshotType": "SpriteSnapshot",
"SnapshotCount": 1,
"SnapshotFormat": "2327a6ec24b44844b3a5e2c1b691****/covers/sprite/990f3820db2948b5b4a13d65d9a4****-{SnapshotCount}.jpg",
"SnapshotRegular": "http://sample/covers/sprite/990f3820db2948b5b4a13d65d9a4****-{SnapshotCount}.jpg",
"JobId": "b3187205eed*****b72adf4eb3840713"
}
]
}