Adds a media file to ApsaraVideo Media Processing (MPS) for processing.
Usage notes
- 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 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.
Limits on QPS
You can call this operation up to 100 times per second. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. For more information, see QPS limits.
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| Action | String | Yes | AddMedia |
The operation that you want to perform. Set the value to AddMedia. |
| FileURL | String | Yes | http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4 |
The path of the input file. You can query the path of the input file in the MPS or OSS console. For more information, see the Triggering and matching rule for a workflow section of this topic.
|
| Title | String | No | mytest |
The title of the media file.
|
| Description | String | No | A test video |
The description of the media file.
|
| CoverURL | String | No | http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png |
The storage location of the thumbnail that you want to specify for the media file. 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.
|
| Tags | String | No | tag1,tag2 |
The tags that you want to add for 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.
|
| MediaWorkflowId | String | No | 07da6c65da7f458997336e0de192**** |
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. |
| MediaWorkflowUserData | String | No | test |
The custom data of the media workflow.
|
| InputUnbind | Boolean | No | false |
Specifies whether to check if the media workflow supports the specified input path. We recommend that you set this parameter to true to avoid errors that may result from invalid paths. Valid values:
|
| CateId | Long | No | 123 |
The ID of the category to which the media file belongs. The value cannot be negative. |
| OverrideParams | String | No | {"subtitleTransNodeName":{"InputConfig":{"Format":"stl","InputFile":{"URL":"http://exampleBucket.oss-cn-hangzhou.aliyuncs.com/package/example/CENG.stl"}}}} |
The subtitle settings that are used to overwrite the original settings.
|
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. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/, the workflow matches the input file.
2. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/, the workflow matches the input file.
3. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/, the workflow matches the input file.
4. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/, the workflow matches the input file.
5. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.flv, the workflow matches the input file.
6. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/CC/, the workflow does not match the input file.
7. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B2/, the workflow does not match the input file.
8. If the URL to which the workflow is bound is http://bucket.oss-cn-hangzhou.aliyuncs.com/A2/B/C/, the workflow does not match the input file.
Only multimedia files can trigger workflows. MPS determines whether to trigger a workflow by checking the file name extension. 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.
|
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 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 is returned 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
| Parameter | Type | Example | Description |
|---|---|---|---|
| RequestId | String | 05F8B913-E9F3-4A6F-9922-48CADA0FFAAD |
The ID of the request. |
| Media | Object |
The detailed information about the media file. |
|
| CreationTime | String | 2016-09-20T03:02:40Z |
The time when the media file was created. |
| CateId | Long | 1 |
The ID of the category to which the media file belongs. |
| Height | String | 1280 |
The height of the media file. |
| CensorState | String | Initiated |
The review status of the video. Valid values:
|
| Tags | Array of String | tag,tag2 |
The tags of the media file. |
| Bitrate | String | 1148.77 |
The bitrate of the media file. |
| MediaId | String | 3e6149d5a8c944c09b1a8d2dc3e4**** |
The ID of the media file. |
| File | Object |
The information about the input file. |
|
| State | String | Normal |
The status of the input file. The default value is Normal. |
| URL | String | http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4 |
The URL of the input file. |
| PublishState | String | Published |
The publishing status of the media file. Valid values:
|
| Description | String | A test video |
The description of the media file. The value is no longer than 1,024 bytes. |
| Width | String | 1280 |
The width of the media file. |
| Size | String | 379860 |
The size of the media file. |
| CoverURL | String | http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png |
The storage location of the media thumbnail. |
| RunIdList | Array of String | null |
The IDs of the executed workflow execution instances. The IDs are separated by commas (,). |
| Duration | String | 2.645333 |
The duration of the media file. |
| Fps | String | 25.0 |
The frame rate of the media file. |
| Title | String | mytest.mp4 |
The title of the media file. The title is no longer than 128 bytes. |
| Format | String | mp4 |
The format of the media file. Valid values: mov, mp4, m4a, 3gp, 3g2, and mj2. |
Examples
Sample requests
http(s)://mts.cn-shanghai.aliyuncs.com/?Action=AddMedia
&FileURL=http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4
&Title=mytest
&Description=A test video
&CoverURL=http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png
&Tags=tag1,tag2
&MediaWorkflowId=07da6c65da7f458997336e0de192****
&MediaWorkflowUserData=test
&InputUnbind=false
&CateId=123
&OverrideParams={"subtitleTransNodeName":{"InputConfig":{"Format":"stl","InputFile":{"URL":"http://exampleBucket.oss-cn-hangzhou.aliyuncs.com/package/example/CENG.stl"}}}}
&<Common request parameters>
Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<AddMediaResponse>
<RequestId>05F8B913-E9F3-4A6F-9922-48CADA0FFAAD</RequestId>
<Media>
<CreationTime>2016-09-20T03:02:40Z</CreationTime>
<CateId>1</CateId>
<Height>1280</Height>
<CensorState>Initiated</CensorState>
<Tags>tag,tag2</Tags>
<Bitrate>1148.77</Bitrate>
<MediaId>3e6149d5a8c944c09b1a8d2dc3e4****</MediaId>
<File>
<State>Normal</State>
<URL>http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test.mp4</URL>
</File>
<PublishState>Published</PublishState>
<Description>A test video</Description>
<Width>1280</Width>
<Size>379860</Size>
<CoverURL>http://bucket.oss-cn-hangzhou.aliyuncs.com/example/1.png</CoverURL>
<RunIdList>{"RunId":["cbad98d35629470fa05ff393d347****"]}</RunIdList>
<Duration>2.645333</Duration>
<Fps>25.0</Fps>
<Title>mytest.mp4</Title>
<Format>mp4</Format>
</Media>
</AddMediaResponse>
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "05F8B913-E9F3-4A6F-9922-48CADA0FFAAD",
"Media" : {
"CreationTime" : "2016-09-20T03:02:40Z",
"CateId" : 1,
"Height" : "1280",
"CensorState" : "Initiated",
"Tags" : [ "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\":[\"cbad98d35629470fa05ff393d347****\"]}" ],
"Duration" : "2.645333",
"Fps" : "25.0",
"Title" : "mytest.mp4",
"Format" : "mp4"
}
}
Error codes
For a list of error codes, visit the API Error Center.