Adds a media file.
Operation description
- You can call this operation to process videos that are uploaded to Object Storage Service (OSS) but not processed. This way, you do not need to upload the videos to OSS again. If you have configured media workflows, OSS automatically notifies ApsaraVideo Media Processing (MPS) when a media file is uploaded to OSS. MPS automatically finds the corresponding workflow in the Active state based on the specified OSS bucket and object. Therefore, in most cases, you do not need to manually call the AddMedia operation to process the media file.
- Media information is automatically obtained only when the specified media workflow is in the Active state. If no media workflow is specified or the specified media workflow is not in the Active state, media information is not obtained.
QPS limit
You can call this operation up to 100 times per second per account. Requests that exceed this limit are dropped and you will experience service interruptions. We recommend that you take note of this limit when you call this operation. For more information, see QPS limit.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
mts:AddMedia | create | *All Resources * |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
FileURL | string | Yes | The URL of the input file. You can obtain the URL in the MPS or OSS console. For more information, see the Triggering and matching rule for a workflow section of this topic.
| http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4 |
Title | string | No | The title of the media file.
| mytest |
Description | string | No | The description of the media file.
| A test video |
CoverURL | string | No | The URL of the thumbnail. To obtain the URL, you can log on to the MPS console and choose Workflows > Media Buckets. Alternatively, you can log on to the OSS console and click My OSS Paths.
| http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png |
Tags | string | No | The tags that you want to add to the media file. Note
In MPS, each tag that is specified for a media file is independent. You can search for all the media files that have the same tags in the Media Library.
| tag1,tag2 |
MediaWorkflowId | string | No | The ID of the media workflow that you want to run for the media file. To query the ID of a media workflow, you can log on to the MPS console or call the AddMediaWorkflow operation. | 07da6c65da7f458997336e0de192**** |
MediaWorkflowUserData | string | No | The custom data of the media workflow.
| test |
InputUnbind | boolean | No | Specifies whether to check if the media workflow supports the specified input path. We recommend that you set this parameter to true to prevent errors that may result from invalid paths. Valid values:
| false |
CateId | long | No | The ID of the category to which the media file belongs. The value cannot be negative. | 123 |
OverrideParams | string | No | The subtitle settings that are used to overwrite the original settings.
| {“subtitleTransNodeName”:{“InputConfig”:{“Format”:”stl”,”InputFile”:{“URL”:”http://exampleBucket.oss-cn-hangzhou.aliyuncs.com/package/example/CENG.stl"}}}} |
Triggering and matching rule for a workflow
MPS checks whether the URL of the input file contains the URL to which the workflow is bound. If yes, the workflow matches the input file and runs. Otherwise, the workflow does not match the input file and does not run. Example: The URL of the input file is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test1.flv
.
1. When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/, the workflow is triggered.
2. When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/, the workflow is triggered.
3.When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A/, the workflow is triggered.
4. When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/, the workflow is triggered.
5. When test.flv is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/, the workflow is triggered.
6. When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/CC/, the workflow is not triggered.
7. When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B2/, the workflow is not triggered.
8. When a media file is added to http://bucket.oss-cn-hangzhou.aliyuncs.com/A2/B/C/, the workflow is not triggered.
NoteWhen you create a media workflow, do not configure the input URL of a workflow to be the same as the prefix of the input URL of another workflow. Otherwise, two workflow execution instances will be triggered for adding one media file. For example, if you specify the test folder for the first workflow triggering rule and the test1 folder for the second workflow triggering rule, the two workflows are triggered when a media file is added to the test1 folder.
File name extension matching
Only multimedia files can trigger workflows. MPS determines whether to trigger a workflow by checking the file name extensions. A workflow is matched for a file that does not have a file name extension or a file with the name extension described in the following table. A file that does not have a file name extension has no separator dot in the file name.
NoteFor SWF files, the snapshot and transcoding features may not deliver optimal performance.
Type | File name extension |
---|---|
Video | 3gp, 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 |
Audio | aac, ac3, acm, amr, ape, caf, flac, m4a, mp3, ra, wav, wma, aiff |
Media workflow message
Media workflows use Alibaba Cloud Message Service (MNS) to send messages to MPS service users. A media workflow sends a message when the Start or Report activity is complete. To receive the message, you must set the queue or notification name on the Start activity. The message generated by the media workflow is stored in the queue or notification. You can use MNS SDK to obtain the message. The following table describes the message specifications.
Parameter | Type | Description |
---|---|---|
RunId | String | The ID of the workflow execution instance. |
Name | String | The name of the activity. |
Type | String | The type of the activity. Valid values: Report and Start. |
State | String | The status of the activity. Valid values: Fail and Success. |
Code | String | The error code returned if the activity fails. The specific error code appears if the activity status is Fail. |
Message | String | The error message returned if the activity fails. The detailed error message is returned if the activity status is Fail. |
MediaWorkflowExecution | MediaWorkflowExecution | The detailed information about the workflow execution instance. |
Response parameters
Examples
Sample success responses
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
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|