Updated on 2024-03-01 GMT+08:00

Pulls media files from URLs

Function

Pulls an audio/video file offline from its URL and uploads it to VOD

Constraints

A maximum of 16 audio and video records can be pulled at a time by calling this API.

URI

POST /v1.0/{project_id}/asset/upload_by_url

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.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

User token. This parameter is mandatory when token authentication is used.

It 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 a token.

Authorization

No

String

Authentication information. This parameter is mandatory for AK/SK authentication.

X-Sdk-Date

No

String

Time when the request is sent. This parameter is mandatory for AK/SK authentication.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

upload_metadatas

Yes

Array of UploadMetaDataByUrl objects

Metadata of a media asset to be created

Table 4 UploadMetaDataByUrl

Parameter

Mandatory

Type

Description

video_type

Yes

String

Format of an uploaded audio/video file

Possible values are: Video files: MP4, TS, MOV, MXF, MPG, FLV, WMV, AVI, M4V, F4V, MPEG, 3GP, ASF, MKV, and M3U8

  • Audio files: MP3, OGG, WAV, WMA, APE, FLAC, AAC, AC3, MMF, AMR, M4A, M4R, WV, and MP2 If an audio file is uploaded, transcoding, watermarking, and subtitling are not supported.

title

Yes

String

Media asset title. The value is UTF-8-encoded and contains a maximum of 128 characters.

url

Yes

String

URL of the audio or video file to be pulled.

NOTE:

The URL must end with a file name extension. Currently, only HTTP and HTTPS are supported. HTTP has security risks. HTTPS is recommended. You are advised not to write sensitive information such as authentication credentials in URLs.

description

No

String

Video description. The value contains a maximum of 1024 characters.

category_id

No

Integer

Media file category ID

You can call the API for Creating a Media File Category to create a media file category, or create a media file category in the category settings on the VOD console and obtain the category ID.

NOTE:

If this parameter is not specified or is set to -1, the uploaded audio/video files fall into the preconfigured Other category.

tags

No

String

Video tag

Each tag contains up to 16 characters and up to 16 tags are allowed.

Use commas (,) to separate tags. The values are UTF-8-encoded.

auto_publish

No

Integer

Whether to publish the content automatically.

The options are as follows:

  • 0: The content is not automatically published.

  • 1: The content is automatically published.

Default value: 1

template_group_name

No

String

Name of a transcoding template group

If this parameter is specified, the specified transcoding template is used to transcode the uploaded audio/video. You can configure a transcoding template on the VOD console. For details, see Transcoding Settings in VOD User Guide.

NOTE:

If both template_group_name and workflow_name are specified, template_group_name takes effect.

auto_encrypt

No

Integer

Whether to automatically encrypt a file

Possible values are:

  • 0: not encrypted

  • 1: encrypted

Default value: 0. If encryption is required, a transcoding template must be configured and the transcoded file must be in HLS format.

auto_preheat

No

Integer

Whether to automatically pre-load content to the CDN

Possible values are:

  • 0: The content is not automatically pre-loaded.

  • 1: The content is automatically pre-loaded.

Default value: 0

thumbnail

No

Thumbnail object

Snapshot parameters

review

No

Review object

Media file review parameters

NOTE:

Only the VOD service in the CN North-Beijing1 and CN North-Beijing4 regions supports this function.

workflow_name

No

String

Workflow name

If this parameter is specified, the specified workflow is used to transcode the uploaded audio/video. You can configure a workflow on the VOD console. For details, see Transcoding Settings in VOD User Guide.

Table 5 Thumbnail

Parameter

Mandatory

Type

Description

type

Yes

String

Snapshot capturing mode.

The options are as follows:

  • time: Snapshots are captured by interval.

  • dots: Snapshots are captured at a specified time point.

  • quantity: Snapshots are captured based on the specified quantity and video duration.

quantity

No

Integer

This parameter is mandatory when type is set to quantity. Snapshots are captured based on the specified quantity and video duration.

Value range: an integer between 1 and 10

quantity_time

No

Integer

This parameter is optional when type is set to quantity. Snapshots are captured based on the specified quantity at a specified interval.

Value range: an integer between 0 and 2,147,483,647

time

No

Integer

Interval for sampling, in seconds.

type is set to time.

Default value: 12

Value range: an integer between 0 and 100

dots

No

Array of integers

This parameter is mandatory when type is set to dots. The array of time points when a snapshot is captured is used.

cover_position

No

Integer

The value indicates which snapshot is specified as the thumbnail.

The default value is 1.

format

No

Integer

Snapshot file format

Possible values are:

  • 1: jpg

The default value is 1.

aspect_ratio

No

Integer

Aspect ratio

Possible values are:

  • 0: adaptive (the original aspect ratio is retained)

  • 1: 16:9

Default value: 0

max_length

No

Integer

The longest side of a snapshot.

Unit: pixel

The width of the snapshot is scaled proportionally with the longest side and input video pixel.

Default value: 480

Table 6 Review

Parameter

Mandatory

Type

Description

template_id

Yes

String

Review template ID. You can obtain the value after configuring the review template on the VOD console. For details, see Review Settings in VOD User Guide.

NOTE:

Only the VOD service in the CN North-Beijing1 and CN North-Beijing4 regions supports this function.

interval

No

Integer

Snapshot check interval. The value range is [0,100]. This parameter is ignored in request parameters.

politics

No

Integer

Confidence of politically sensitive content detection. The value range is [0,100]. This parameter is ignored in request parameters. A higher confidence level indicates a more reliable review result. If this function is disabled or the value is set to 0, this check is not performed.

terrorism

No

Integer

Confidence of terrorism-related content detection. The value range is [0,100]. This parameter is ignored in request parameters. A higher confidence level indicates a more reliable review result. If this function is disabled or the value is set to 0, this check is not performed.

porn

No

Integer

Confidence of pornographic content detection. The value range is [0,100]. This parameter is ignored in request parameters. A higher confidence level indicates a more reliable review result. If this function is disabled or the value is set to 0, this check is not performed.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

upload_assets

Array of UploadAsset objects

Metadata of a media asset to be created

Table 8 UploadAsset

Parameter

Type

Description

url

String

URL of the audio or video file to be pulled

asset_id

String

ID of the new media asset

error_code

String

Error code

error_msg

String

Error description

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Example Requests

Creates a media file and uses the URL pull mode to pull a media file offline from its URL and upload it to VOD.

POST https://{endpoint}/v1.0/{project_id}/asset/upload_by_url

{
  "upload_metadatas" : [ {
    "url" : "https://mpc-test.obs.cn-north-4.myhuaweicloud.com/Avatar_480P.mp4",
    "title" : "Avatar test test",
    "video_type" : "MP4",
    "description" : "Avatar, test",
    "category_id" : 1,
    "tags" : "mytags",
    "auto_publish" : 1
  }, {
    "url" : "https://mpc-test.obs.cn-north-4.myhuaweicloud.com/Avatar_720.mp4",
    "title" : "Avatar test test",
    "video_type" : "MP4",
    "description" : "Avatar, test",
    "category_id" : 1,
    "tags" : "mytags",
    "auto_publish" : 1
  } ]
}

Example Responses

Status code: 200

The information is returned when the request succeeds.

{
  "upload_assets" : [ {
    "url" : "https://mpc-test.obs.cn-north-4.myhuaweicloud.com/Avatar_480P.mp4",
    "asset_id" : "f488337c31c8e4622f1590735b134c65",
    "error_code" : null,
    "error_msg" : null
  }, {
    "url" : "https://mpc-test.obs.cn-north-4.myhuaweicloud.com/Avatar_720.mp4",
    "asset_id" : "f488337c31c8e4622f1590525b134c65",
    "error_code" : null,
    "error_msg" : null
  } ]
}

Status code: 400

The information is returned when the request fails.

{
  "error_code" : "VOD.10003",
  "error_msg" : "The specified key does not exist."
}

Status Codes

Status Code

Description

200

The information is returned when the request succeeds.

400

The information is returned when the request fails.

Error Codes

See Error Codes.