Updated on 2023-12-25 GMT+08:00

Querying Video Parsing Tasks

Function

This API is used to query the status and results of one or more video parsing tasks.

Calling Method

For details, see Calling APIs.

URI

GET /v1/{project_id}/extract-metadata

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the 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 task IDs can be queried at a time.

status

No

String

Task status.

Possible values:

  • INIT: initialized

  • WAITING: pending

  • PROCESSING: running

  • SUCCEED: completed

  • FAILED: failed

  • CANCELED: canceled

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-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.

x-language

No

String

Client language.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

total

Integer

Total number of tasks

tasks

Array of ExtractTask objects

Tasks.

Table 5 ExtractTask

Parameter

Type

Description

task_id

String

Task ID.

status

String

Task status.

Possible values:

  • INIT: initialized

  • WAITING: pending

  • PROCESSING: running

  • SUCCEED: successful

  • FAILED: failed

  • CANCELED: canceled

create_time

String

Task creation time.

start_time

String

Task start time.

end_time

String

Task end time.

error_code

String

Return code of a task

description

String

Error description.

user_data

String

User data.

input

ObsObjInfo object

Input file information.

output

ObsObjInfo object

Output file information.

metadata

MetaData object

Output parameter.

Table 6 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

OBS object path, which complies with the OSS Object definition.

  • If this parameter is used for an input, an object must be specified.

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

file_name

String

File name

  • 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 specified by MPC.

When it is used as the output file name:

  • Specifies the name of the output file. This parameter is valid for packaging.

  • If the output file name needs to be specified during transcoding, use the output_filenames parameter.

  • This parameter is valid for parsing. If a file name is specified during parsing, the parsing parameters are written to the specified file name and the file metadata is obtained through the query API response in JSON format.

  • This parameter is invalid for snapshot capturing.

  • This parameter is invalid for conversion into animated GIFs.

Table 7 MetaData

Parameter

Type

Description

size

Long

File size Unit: byte

duration_ms

Double

Video duration, with decimal places Unit: second

duration

Long

Video duration Unit: second

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

Table 8 VideoInfo

Parameter

Type

Description

width

Integer

Video width

height

Integer

Video height

bitrate

Integer

Video bitrate Unit: kbit/s

bitrate_bps

Long

Video bitrate Unit: 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 9 AudioInfo

Parameter

Type

Description

codec

String

Audio codec

sample

Integer

Audio sampling rate

channels

Integer

Number of audio channels

bitrate

Integer

Audio bitrate Unit: kbit/s

bitrate_bps

Long

Audio bitrate Unit: bit/s

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Example Requests

GET https://{endpoint}/v1/{project_id}/extract-metadata?task_id=7967

Example Responses

Status code: 200

Video parsing task queried successfully.

{
  "total" : 1,
  "tasks" : [ {
    "task_id" : 7967,
    "status" : "SUCCEED",
    "create_time" : 20201119103821,
    "start_time" : 20201119103822,
    "end_time" : 20201119103827,
    "description" : "The task has completed.",
    "input" : {
      "bucket" : "example-bucket",
      "location" : "region01",
      "object" : "example-path/input.mp4"
    },
    "output" : {
      "bucket" : "example-bucket",
      "location" : "region01",
      "object" : "example-path/output",
      "file_name" : "video_001.txt"
    },
    "metadata" : {
      "size" : 43231240,
      "duration_ms" : 60.186,
      "duration" : 60,
      "format" : "MP4",
      "bitrate" : 5605,
      "video" : [ {
        "width" : 3824,
        "height" : 2152,
        "bitrate" : 5481,
        "bitrate_bps" : 5613152,
        "frame_rate" : 23,
        "codec" : "H.265"
      } ],
      "audio" : [ {
        "codec" : "AAC",
        "sample" : 48000,
        "channels" : 2,
        "bitrate" : 124,
        "bitrate_bps" : 127992
      } ]
    }
  } ]
}

Status code: 400

Failed to query the video parsing task.

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

Status Codes

Status Code

Description

200

Video parsing task queried successfully.

400

Failed to query the video parsing task.

Error Codes

See Error Codes.