All Products
Search
Document Center

ApsaraVideo Media Processing:AddMedia

Last Updated:Oct 13, 2026

Submits a job to add media.

Operation description

  • If you have existing videos in OSS, you can use this operation to process them without re-uploading the videos to OSS. If a workflow is configured, OSS automatically notifies ApsaraVideo Media Processing (MPS) after a media file is uploaded to OSS. Based on the configured OSS bucket, the object automatically matches and triggers an active workflow. Therefore, you usually do not need to manually call the AddMedia operation to process files.

  • Media information is automatically retrieved only when an active workflow is specified to process the media file. If no workflow is specified or a workflow in another state is specified, media information is not retrieved.

QPS limit

The QPS limit for a single user for this operation is 100 calls per second. If the limit is exceeded, API calls are throttled, which may affect your business. Make API calls properly. For more information, see QPS limits.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

mts:AddMedia

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

FileURL

string

Yes

The path of the input file. You can obtain the path from the MPS or OSS console. For detailed trigger rules, see Workflow trigger matching rules below.

  • Only OSS HTTP URLs are supported. CDN URLs and HTTPS URLs are not supported.

  • The URL cannot exceed 3,200 bytes in length.

  • The URL must comply with RFC 2396 and be encoded in UTF-8 and URL-encoded. For more information, see URL encoding.

http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4

Title

string

No

The title of the media file.

  • The title cannot exceed 128 bytes in length.

  • The title must be encoded in UTF-8.

mytest

Description

string

No

The description.

  • The description cannot exceed 1,024 bytes in length.

  • The description must be encoded in UTF-8.

A test video

CoverURL

string

No

The URL of the cover image. This is the storage address of the cover image that you want to set. You can obtain the URL by choosing MPS Console > Workflows > Media Buckets or OSS Console > My Access Paths.

  • The URL cannot exceed 3,200 bytes in length.

  • The URL must comply with RFC 2396 and be encoded in UTF-8 and URL-encoded. For more information, see URL encoding.

http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png

Tags

string

No

The list of tags.

Note

In ApsaraVideo Media Processing, each tag of a media file is independent. You can search the Media Library to find all media files that have the same tag.

  • Separate multiple tags with commas (,). You can specify up to 16 tags.

  • A single tag cannot exceed 32 bytes in length.

  • The tags must be encoded in UTF-8.

tag1,tag2

MediaWorkflowId

string

No

The ID of the media workflow. You can obtain the ID from the MPS console or by calling the Add a media workflow operation.

Note
  • The task for this parameter is an asynchronous task. After the task is submitted, it is not completed immediately but queued for asynchronous execution in the background.

07da6c65da7f458997336e0de192****

MediaWorkflowUserData

string

No

The custom user data of the media workflow.

  • The data cannot exceed 1,024 bytes in length.

  • The data must be encoded in UTF-8.

test

InputUnbind

boolean

No

Specifies whether to check whether the specified workflow supports the input path. We recommend that you set this parameter to true to avoid errors caused by incorrect paths. Valid values:

  • true: checks the input path.

  • false: does not check the input path.

false

CateId

integer

No

The ID of the category to which the media file belongs. The ID cannot be a negative number.

123

OverrideParams

string

No

The override parameters.

  • Example 1: Override subtitles for HLS packaging: {"WebVTTSubtitleOverrides",[{"RefActivityName":"subtitleNode","WebVTTSubtitleURL":"http://test.oss-cn-hangzhou.aliyuncs.com/example1.vtt"}]}.

  • Example 2: Override subtitles for DASH packaging: {"subtitleTransNodeName":{"InputConfig":{"Format":"stl","InputFile":{"URL":"http://subtitleBucket.oss-cn-hangzhou.aliyuncs.com/package/example/CENG.stl"}}}}.

{“subtitleTransNodeName”:{“InputConfig”:{“Format”:”stl”,”InputFile”:{“URL”:”http://exampleBucket.oss-cn-hangzhou.aliyuncs.com/package/example/CENG.stl"}}}}

Workflow trigger matching rules

The rule matching execution policy is as follows: Based on the path of the new file, the system checks the location bound to the workflow. If the path of the new file contains the string bound to the rule, a match occurs. Otherwise, no match occurs. For example, if the file path is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test1.flv, the matching rules are as follows:

1. http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/          Matched
2. http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/            Matched
3. http://bucket.oss-cn-hangzhou.aliyuncs.com/A/              Matched
4. http://bucket.oss-cn-hangzhou.aliyuncs.com/                Matched
5. http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.flv  Matched
6. http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/CC/         Not matched
7. http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B2/           Not matched
8. http://bucket.oss-cn-hangzhou.aliyuncs.com/A2/B/C/         Not matched
Note

When you add a media workflow, do not configure the input path of one workflow as a prefix of the input path of another workflow. Otherwise, a single incremental file may trigger two workflow execution instances. For example, if the input paths of two workflows are configured as test and test1, an input file uploaded to the test1 folder also matches the test prefix, which triggers two workflow execution instances.

Match file name extensions

The trigger requires that the file must be a multimedia file. The Media Library service determines this based on the file name extension. The file either has no extension (the file name does not contain the extension separator ".") or the extension complies with the following rules:

Note

For SWF files, the quality of snapshot and transcoding services is not guaranteed.

TypeExtension
Video3gp, asf, avi, dat, dv, flv, f4v, gif, m2t, m3u8, m4v, mj2, mjpeg, mkv, mov, mp4, mpe, mpg, mpeg, mts, ogg, qt, rm, rmvb, swf, ts, vob, wmv, webm
Audioaac, ac3, acm, amr, ape, caf, flac, m4a, mp3, ra, wav, wma, aiff

Media workflow messages

Media workflows use Alibaba Cloud Message Service (formerly MNS) to send messages to video cloud service access parties. A media workflow sends a message when a Start or Report activity node is completed. To receive messages, you must configure the queue or topic name in the Settings of the Start activity. Messages generated by the media workflow are stored in the log broker, such as a queue or topic. You can use the Message Service SDK to obtain messages. The message specifications are as follows:

NameTypeDescription
RunIdStringThe workflow execution ID.
NameStringThe activity name.
TypeStringThe activity type. Valid values: Report and Start.
StateStringThe activity status. Valid values: Fail and Success.
CodeStringThe error code. If the activity status is Fail, a specific error code is returned.
MessageStringThe error message. If the activity status is Fail, a detailed error description is returned.
MediaWorkflowExecutionMediaWorkflowExecutionThe media workflow execution information.

Response elements

Element

Type

Description

Example

object

The response parameters.

RequestId

string

The request ID.

05F8B913-E9F3-4A6F-9922-48CADA0FFAAD

Media

object

The media information.

CreationTime

string

The time when the media file was created. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

2016-09-20T03:02:40Z

CateId

integer

The category ID.

1

Height

string

The height of the media file.

1280

CensorState

string

The content moderation status of the video. Valid values:

  • Initiated: The video is uploaded but the moderation is not completed.

  • Pass: The video is uploaded and passed the moderation.

Initiated

Tags

object

Tag

array

The tag.

string

The list of tags.

tag,tag2

Bitrate

string

The bitrate.

1148.77

MediaId

string

The media ID.

3e6149d5a8c944c09b1a8d2dc3e4****

File

object

The original file.

State

string

The file status. Default value: Normal.

Normal

URL

string

The file URL.

http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4

PublishState

string

The publish status of the media file, which indicates whether the media file is published. Valid values:

  • Initiated: The media file is in the initial state.

  • UnPublish: The media file is not published. The playback permission of the OSS file is Private.

  • Published: The media file is published. The playback permission of the OSS file is Default.

Published

Description

string

The description. The description cannot exceed 1,024 bytes in length.

A test video

Width

string

The width of the media file.

1280

Size

string

The size of the media file.

379860

CoverURL

string

The URL of the cover image.

http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png

RunIdList

object

RunId

array

The list of media workflow execution instance IDs.

string

The list of executed media workflow execution instance IDs, separated by commas (,).

{"RunId":["cbad98d35629470fa05ff393d347****"]}

Duration

string

The duration of the media file.

2.645333

Fps

string

The frame rate of the media file.

25.0

Title

string

The title of the media file. The title cannot exceed 128 bytes in length.

mytest.mp4

Format

string

The format. Valid values: mov, mp4, m4a, 3gp, 3g2, and mj2.

mp4

Examples

Success response

JSON format

{
  "RequestId": "05F8B913-E9F3-4A6F-9922-48CADA0FFAAD",
  "Media": {
    "CreationTime": "2016-09-20T03:02:40Z",
    "CateId": 1,
    "Height": "1280",
    "CensorState": "Initiated",
    "Tags": {
      "Tag": [
        "tag,tag2"
      ]
    },
    "Bitrate": "1148.77",
    "MediaId": "3e6149d5a8c944c09b1a8d2dc3e4****",
    "File": {
      "State": "Normal",
      "URL": "http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4"
    },
    "PublishState": "Published",
    "Description": "A test video",
    "Width": "1280",
    "Size": "379860",
    "CoverURL": "http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png",
    "RunIdList": {
      "RunId": [
        "{\"RunId\":[\"cbad98d35629470fa05ff393d347****\"]}"
      ]
    },
    "Duration": "2.645333",
    "Fps": "25.0",
    "Title": "mytest.mp4",
    "Format": "mp4"
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.