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
Test
RAM authorization
|
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.
|
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.
|
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.
|
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.
|
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
|
07da6c65da7f458997336e0de192**** |
| MediaWorkflowUserData |
string |
No |
The custom user data of the media workflow.
|
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:
|
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.
|
{“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
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:
For SWF files, the quality of snapshot and transcoding services is not guaranteed.
| Type | 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 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:
| Name | Type | Description |
| RunId | String | The workflow execution ID. |
| Name | String | The activity name. |
| Type | String | The activity type. Valid values: Report and Start. |
| State | String | The activity status. Valid values: Fail and Success. |
| Code | String | The error code. If the activity status is Fail, a specific error code is returned. |
| Message | String | The error message. If the activity status is Fail, a detailed error description is returned. |
| MediaWorkflowExecution | MediaWorkflowExecution | The 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 |
| 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:
|
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.