Creating an Animated GIF Task
Function
This API is used to create an animated GIF task to convert a complete video file or part of a video file into an animated GIF file. Ensure that an input media file is stored in an OBS bucket in the same region as MPC and the permission to access the OBS bucket has been granted.
URI
POST /v1/{project_id}/animated-graphics
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID. For details about how to obtain a project ID, see Obtaining a Project ID. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | No | String | User token. The token is obtained by calling the IAM API used to obtain a user token. The token is the value of X-Subject-Token in the response header. |
| 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 | No | ObsObjInfo object | Input file information |
| output | No | ObsObjInfo object | Output file information |
| user_data | No | String | Custom user data |
| output_param | No | AnimatedGraphicsOutputParam object | Animated GIF parameters |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| bucket | Yes | String | OBS bucket name |
| location | Yes | String | Region where an OBS bucket is located. It must be the same as the region where MPC is deployed. |
| object | Yes | String | File path.
|
| file_name | No | String | Name of an output file. This parameter is valid only for packaging tasks.
|
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| format | No | String | Format of an output file. Currently, only GIF format is supported. |
| width | Yes | Integer | Width of an output file. The value is -1, 0, or a multiple of 2 from 32 to 3,840. NOTE:
|
| height | Yes | Integer | Height of an output file. The value is -1, 0, or a multiple of 2 from 32 to 2,160. NOTE:
|
| start | Yes | Integer | Start time Unit: millisecond |
| end | Yes | Integer | End time Unit: millisecond The difference between end and start cannot exceed 60 seconds. |
| frame_rate | No | Integer | Frame rate of the output file. Value range: 1 to 75 |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| task_id | String | Task ID |
| status | String | Task status. |
| create_time | String | Time when a task is created |
| output | ObsObjInfo object | Output file information |
| output_file_name | String | Name of an output file. |
| description | String | Task description. If a task is abnormal, this field indicates error details. |
| metadata | MetaData object | Metadata of a video file |
| Parameter | Type | Description |
|---|---|---|
| bucket | String | OBS bucket name |
| location | String | Region where an OBS bucket is located. It must be the same as the region where MPC is deployed. |
| object | String | File path.
|
| file_name | String | Name of an output file. This parameter is valid only for packaging tasks.
|
| Parameter | Type | Description |
|---|---|---|
| size | Long | File size |
| duration_ms | Double | Video duration (unit: second), with decimal places. |
| duration | Long | Video duration Unit: s |
| format | String | File container format |
| bitrate | Long | Total bitrate. Unit: bit/s. |
| video | Array of VideoInfo objects | Video metadata |
| audio | Array of AudioInfo objects | Audio metadata |
| Parameter | Type | Description |
|---|---|---|
| width | Integer | Video width |
| height | Integer | Video height |
| bitrate | Integer | Video bitrate, in kbit/s |
| bitrate_bps | Long | Video bitrate, in bit/s |
| frame_rate | Integer | Frame rate. The value is 0 or ranges from 5 to 60. The value 0 indicates adaptive frame rate. Unit: FPS NOTE: If the configured frame rate is not within the value range, the value is automatically changed to 0. If the configured frame rate is higher than the frame rate of the input file, the value is automatically changed to the frame rate of the input file. |
| codec | String | Video codec |
| Parameter | Type | Description |
|---|---|---|
| codec | String | Audio codec |
| sample | Integer | Audio sampling rate |
| channels | Integer | Number of audio channels |
| bitrate | Integer | Audio bitrate, in kbit/s |
| bitrate_bps | Long | Audio bitrate, in bit/s |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code |
| error_msg | String | Error description |
Example Requests
POST https://{endpoint}/v1/{project_id}/animated-graphics
{
"input": {
"bucket": "obs-63bc",
"location": "region1",
"object": "thumb.mp4"
},
"output": {
"bucket": "obs-63bc",
"location": "region1",
"object": "/b",
"file_name": "test_mpc.gif"
},
"output_param": {
"format": "gif",
"width": 480,
"height": 360,
"frame_rate": 15,
"start": 100,
"end": 250
}
}
Example Responses
Status code: 200
Animated GIF task created successfully.
{
"task_id" : 100211
} Status code: 400
Failed to create an animated GIF task.
{
"error_code" : "MPC.10202",
"error_msg" : "Invalid request parameter."
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Animated GIF task created successfully. |
| 400 | Failed to create an animated GIF task. |
Error Codes
See Error Codes.
Last Article: Animated GIF APIs
Next Article: Querying Animated GIF Tasks
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.