Submits a job to add media.
Operation description
If you have existing videos stored in OSS, you can use this operation to process them without re-uploading the videos to OSS. If you have configured a media workflow, OSS automatically notifies ApsaraVideo Media Processing after a media file is uploaded to OSS. Based on the configured OSS bucket and object, the system automatically matches and runs active workflows. Therefore, you do not need to manually call the AddMedia operation to process files in most cases.
Media information is automatically obtained only when you specify an active workflow to process media files. If you do not specify a workflow or specify a workflow in another state, media information is not obtained.
QPS limit
The QPS limit for a single user for this operation is 100 calls per second. If the limit is exceeded, the API call is throttled, which may affect your business. Call this operation properly. For more information, see QPS limit.
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 ApsaraVideo Media Processing 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 media title.
|
mytest |
| Description |
string |
No |
The description.
|
A test video |
| CoverURL |
string |
No |
The cover URL. This is the storage address of the cover that you want to set. You can obtain the address from ApsaraVideo Media Processing console > Workflow Management > Media Bucket or OSS console > My Access Path.
|
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 each media is independent. You can search the Media Library to find all media that have the same tag.
|
tag1,tag2 |
| MediaWorkflowId |
string |
No |
The media workflow ID. You can obtain the ID from the ApsaraVideo Media Processing console or by calling the AddMediaWorkflow operation. Note
|
07da6c65da7f458997336e0de192**** |
| MediaWorkflowUserData |
string |
No |
The custom data of the media workflow.
|
test |
| InputUnbind |
boolean |
No |
Specifies whether to check that the specified workflow supports the input path. Set this parameter to true to avoid errors caused by incorrect paths. Valid values:
|
false |
| CateId |
integer |
No |
The category ID of the media. Negative values are not allowed. |
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, the rule is matched. Otherwise, the rule is not matched. For example, for http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test1.flv, the rules are:
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 triggers two workflow execution instances. For example, if the input paths of two workflows are configured as test and test1, when an input file is uploaded to the test1 folder, it also matches the test prefix, triggering two workflow execution instances.
Matching file name extensions
The trigger requires multimedia files. The Media Library determines file types by file name extensions. A file either has no file name extension (the file name does not contain the extension separator ".") or has a file name extension that 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 Simple Message Queue (formerly MNS) to send messages to video cloud service consumers. A media workflow sends messages when Start or Report activity nodes are completed. To receive messages, set the queue or notification name on the Start activity. Messages generated by the media workflow are stored in the queue or notification. You can use the Simple Message Queue (formerly MNS) SDK to retrieve 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, Start. |
| State | String | The activity status. Valid values: Fail, Success. |
| Code | String | The error code. A specific error code is returned if the activity status is Fail. |
| Message | String | The error message. A detailed error description is returned if the activity status is Fail. |
| 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 creation time. |
2016-09-20T03:02:40Z |
| CateId |
integer |
The category ID. |
1 |
| Height |
string |
The height of the media file. |
1280 |
| CensorState |
string |
The video moderation status. 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. The default value is Normal. |
Normal |
| URL |
string |
The file URL. |
http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4 |
| PublishState |
string |
The media publish status, which indicates whether the media is published externally. Valid values:
|
Published |
| Description |
string |
The description. The value cannot exceed 1,024 bytes. |
A test video |
| Width |
string |
The width of the media file. |
1280 |
| Size |
string |
The size of the media file. |
379860 |
| CoverURL |
string |
The cover URL. |
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 media title. The value cannot exceed 128 bytes. |
mytest.mp4 |
| Format |
string |
The format. Supported formats: 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.