Creating a Snapshot Task
Function
This API is used to create a task for capturing snapshots from the first to the last frame at every set interval.
Ensure that an input media file is stored in an OBS bucket in the same region as MPC and the permission for accessing the OBS bucket has been granted to MPC.
Constraints:
Currently, only JPG image files can be generated.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/thumbnails
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. (tag:hc,hk) Project ID. For details about how to obtain the project ID, see [Obtaining a Project ID]. (tag:hcso,g42,cmcc) |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
User token The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Authorization |
No |
String |
Authentication information. This parameter is mandatory when AK/SK-based authentication is used. |
X-Project_Id |
No |
String |
Project ID. This parameter is mandatory when AK/SK-based authentication is used. It is same as the project ID in path parameters. |
X-Sdk-Date |
No |
String |
Time when the request is sent. This parameter is mandatory when AK/SK-based authentication is used. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
input |
Yes |
ObsObjInfo object |
Storage location of an input file |
output |
Yes |
ObsObjInfo object |
Storage location of an output file |
user_data |
No |
String |
Custom user data |
thumbnail_para |
Yes |
ThumbnailPara object |
Snapshot parameters |
tar |
No |
Integer |
Whether to compress captured snapshots to a TAR package. Possible values: Default value: 1 |
sync |
No |
Integer |
Whether to enable synchronous processing. Synchronous processing quickly locates the snapshot position to capture a snapshot. The options are as follows: Default value: 0 |
original_dir |
No |
Integer |
Whether to use the original output directory. Possible values:
Default value: 0 |
Response Parameters
Status code: 202
Parameter |
Type |
Description |
---|---|---|
task_id |
String |
Task ID |
status |
String |
Task status |
create_time |
String |
Time when a task is created |
output |
ObsObjInfo object |
Storage location of snapshots |
output_file_name |
String |
Snapshot file name |
thumbnail_time |
String |
Capture time |
description |
String |
Task description |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code |
error_msg |
String |
Error description |
Example Requests
-
Creates an asynchronous snapshot capturing task to capture snapshots from a video at every set interval.
POST https://{endpoint}/v1/{project_id}/thumbnails { "input" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-path/input.mp4" }, "output" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-path/output" }, "tar" : 1, "thumbnail_para" : { "time" : 2, "format" : 1, "max_length" : 480 }, "sync" : 0 }
-
Creates a synchronous snapshot capturing task (sync set to 1) to capture snapshots from a video at every set interval.
POST https://{endpoint}/v1/{project_id}/thumbnails { "input" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-path/input.mp4" }, "output" : { "bucket" : "example-bucket", "location" : "region01", "object" : "example-path/output" }, "tar" : 1, "thumbnail_para" : { "time" : 2, "format" : 1, "max_length" : 480 }, "sync" : 1 }
Example Responses
Status code: 202
Snapshot task created successfully.
-
Asynchronous snapshot capturing task created.
{ "task_id" : "100211" }
-
Synchronous snapshot capturing task created.
{ "task_id" : "100212", "status" : "FINISHED", "create_time" : "20231201020412", "output" : { "bucket" : "bucket-demo", "location" : "cn-north-4", "object" : "output/demo_object", "file_name" : "" }, "output_file_name" : "H_270.png", "thumbnail_time" : "30", "description" : "Task completed." }
Status code: 400
Failed to create a snapshot task.
{ "error_code" : "MPC.10202", "error_msg" : "Invalid request parameter" }
Status Codes
Status Code |
Description |
---|---|
202 |
Snapshot task created successfully. |
400 |
Failed to create a snapshot task. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot