Querying Transcoding Tasks

Function

This API is used to query one or more transcoding tasks.

URI

GET /v1/{project_id}/transcodings

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

task_id

No

Array

Task ID. A maximum of 10 transcoding task IDs can be queried at a time.

status

No

String

Task status.

Possible values are:

  • WAITING: queuing

  • TRANSCODING: running

  • SUCCEEDED: completed

  • FAILED: failed

  • CANCELED: deleted

  • NEED_TO_BE_AUDIT: pending review

start_time

No

String

Start time.

If task_id is specified, this parameter is invalid. Its format is yyyymmddhhmmss. The value must be a UTC time irrelevant to the time zone.

end_time

No

String

End time.

If task_id is specified, this parameter is invalid. Its format is yyyymmddhhmmss. The value must be a UTC time irrelevant to the time zone.

page

No

Integer

Page number. If task_id is specified, this parameter is invalid.

Default value: 0.

size

No

Integer

Number of records on each page. If task_id is specified, this parameter is invalid.

The value ranges from 1 to 100.

Default value: 10

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

x-language

No

String

Client language.

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.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

task_array

Array of QueryTranscodingsTaskResponse objects

List of transcoding tasks

is_truncated

Integer

Whether the query results are truncated. Possible values are:

  • 1: Query results are truncated. Some results are not returned. You can set the page and size parameters to continue the query.

  • 0: Query results are not truncated. All results are returned.

total

Integer

Number of records

Table 5 QueryTranscodingsTaskResponse

Parameter

Type

Description

task_id

String

Task ID

status

String

Task status

create_time

String

Task start time

end_time

String

Task end time

trans_template_id

Array of integers

ID of transcoding templates

input

ObsObjInfo object

Storage location of an input file. The information includes the location, bucket name, and path.

output

ObsObjInfo object

Storage location of an output file. The information includes the location, bucket name, and path.

output_file_name

Array of strings

Name of the output file. The value is of the array type and may contain multiple names, including snapshot names.

user_data

String

Custom user data

error_code

String

Status code of a transcoding task

description

String

Task description. If an error occurs in a transcoding task, this field indicates the error cause.

tips

String

Message displayed if the audio sampling rate is too low

transcode_detail

TranscodeDetail object

Output information of snapshots

thumbnail_output

ObsObjInfo object

Output information of snapshots. The information includes the location, bucket name, and path.

thumbnail_outputname

String

Name of the snapshot package

pic_info

Array of PicInfo objects

Snapshot file information

Table 6 TranscodeDetail

Parameter

Type

Description

multitask_info

Array of MultiTaskInfo objects

Details about failed transcoding in the case of one-in and multiple-out

input_file

SourceInfo object

Input file information

Table 7 MultiTaskInfo

Parameter

Type

Description

template_id

Integer

Template ID

error

ErrorResponse object

Error message about failed transcoding

output_file

SourceInfo object

Information about a single output

Table 8 ErrorResponse

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Table 9 SourceInfo

Parameter

Type

Description

duration

Integer

File duration, in seconds

duration_ms

Long

File duration, in milliseconds

format

String

File format

size

Long

File size

video_info

VideoInfo object

Video information

audio_info

Array of AudioInfo objects

Audio information

Table 10 VideoInfo

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

Table 11 AudioInfo

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

Table 12 ObsObjInfo

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.

  • If this parameter is used for an input, a specific path must be specified.

  • If this parameter is used for an output, only the directory for storing the outputs needs to be specified.

file_name

String

Name of an output file. This parameter is valid only for packaging tasks.

  • If this parameter is specified, the output object name is object/file_name.

  • If this parameter is not specified, the output object name is object/xxx, where xxx is allocated by MPC.

Table 13 PicInfo

Parameter

Type

Description

pic_name

String

Snapshot file name

Status code: 400

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Example Requests

GET https://{endpoint}/v1/{project_id}/transcodings?task_id=22123973

Example Responses

Status code: 200

Transcoding task queried successfully.

{
  "is_truncated" : 0,
  "total" : 1,
  "task_array" : [ {
    "task_id" : 22123973,
    "status" : "SUCCEEDED",
    "create_time" : 20200310031605,
    "end_time" : 20200310031623,
    "trans_template_id" : [ 4 ],
    "input" : {
      "bucket" : "zitest",
      "location" : "cn-north-7",
      "object" : "ziqiantest.mp4"
    },
    "output" : {
      "bucket" : "zitest",
      "location" : "cn-north-7",
      "object" : "test"
    },
    "output_file_name" : [ "ziqiantest_1_480X270_199_0.m3u8" ],
    "transcode_detail" : {
      "multitask_info" : [ {
        "template_id" : 4,
        "output_file" : {
          "duration" : 59,
          "duration_ms" : 0,
          "format" : "HLS",
          "size" : 2180,
          "video_info" : {
            "width" : 480,
            "height" : 270,
            "bitrate" : 231,
            "bitrate_bps" : 0,
            "frame_rate" : 25000,
            "codec" : "H264"
          },
          "audio_info" : [ {
            "codec" : "HEAAC",
            "sample" : 44100,
            "channels" : 2,
            "bitrate" : 64,
            "bitrate_bps" : 0
          } ]
        }
      } ],
      "input_file" : {
        "duration" : 59,
        "duration_ms" : 0,
        "format" : "MOV",
        "size" : 2494653,
        "video_info" : {
          "width" : 480,
          "height" : 270,
          "bitrate" : 199,
          "bitrate_bps" : 0,
          "frame_rate" : 25000,
          "codec" : "HEVC"
        },
        "audio_info" : [ {
          "codec" : "AAC",
          "sample" : 48000,
          "channels" : 2,
          "bitrate" : 128,
          "bitrate_bps" : 0
        } ]
      }
    }
  } ]
}

Status code: 400

Failed to query the transcoding task.

{
  "error_code" : "MPC.10202",
  "error_msg" : "Invalid request parameter"
}

Status Codes

Status Code

Description

200

Transcoding task queried successfully.

400

Failed to query the transcoding task.

Error Codes

See Error Codes.