edit-icon download-icon

AddMedia

Last Updated: Apr 20, 2018

Description

The AddMedia API adds media.

Note:

  • After workflows are configured and a media file is uploaded to OSS, OSS automatically notifies Media Processing and Media Processing identifies the active workflow that matches a specific OSS bucket and object. Then the matched workflow is automatically executed. Therefore, in normal cases, files are automatically processed using the AddMedia API without manual intervention, but you can manually call this API to process inventory video files in OSS without uploading.

  • Media information is automatically obtained when the specified active workflow is executed. When no workflow is specified, media information is not obtained.

Request parameters

Parameter Type Required or not Description
Action String Yes API of the action, system required parameter. Set this parameter to AddMedia.
FileURL String Yes Path to a media file, which consists of up to 3,200 bytes. The URL format follows the RFC 2396 standard. (The URL is subject to UTF-8 encoding and URL encoding.)
Title String No Media title, which consists of up to 128 UTF-8 encoded bytes.
Description String No Description, which consists of up to 1,024 UTF-8 encoded bytes.
CoverURL String No Cover, which consists of up to 3,200 bytes. The URL format follows the RFC 2396 standard. (The URL is subject to UTF-8 encoding and URL encoding.)
CateId Long No Category ID, which cannot be a negative number.
Tags String No A list of up to 16 tags separated by commas (,). Each tag consists of up to 32 UTF-8 encoded bytes.
MediaWorkflowId String No ID of a media workflow.
MediaWorkflowUserData String No Custom data of a media workflow, which consists of up to 1,024 UTF-8 encoded bytes.
OverrideParams Json No Override parameters. Example: {“WebVTTSubtitleOverrides”,[{“RefActivityName”:”subtitleNode”,”WebVTTSubtitleURL”:”http://test.oss-cn-hangzhou.aliyuncs.com/subtitle1.vtt"}]}
  • Matching rules for workflow triggering

    Matching rule execution policy:

    Check the workflow binding position based on the path to the new file. A match is found if the path contains the rule-bound string.For the path http://bucket.oss-cn-hangzhou.aliyuncs.com/A/B/C/test1.flv, the matching rules are as follows:

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

    Note: Do not configure the input path of a workflow as the prefix of the input path of another workflow; otherwise, two workflow execution instances are triggered for the same incremental file. For example, the input path of a workflow is “test” and that of another workflow is “test1”. After an input file is uploaded to the test1 folder, two workflow execution instances are triggered because the test1 folder also matches the “test” prefix.*

  • File name extension matching

    Only a multimedia file can trigger a media workflow, which is determined by the media repository using the file name extension. The file does not contain an extension (the file name does not contain the extension separator “.”) or the extension meets the following rules:

    Note: QoS is not guaranteed for files with the .swf file name extension in terms of screenshot and transcoding.

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, and webm
Audio aac, ac3, acm, amr, ape, caf, flac, m4a, mp3, ra, wav, wma, and aiff
  • Media workflow message

    Media workflows use Alibaba Cloud Message Service to send messages to users that access video cloud services after the Start and Report activities are completed. If you want to receive messages, set the MNS queue name and notification name on the Start node and use the Message Service SDK to obtain the messages that are stored in the MNS queue or notification. The message format is as follows:

Name Type Description
RunId String Workflow execution instance ID
Name String Activity name
Type String Activity type, which can be Report or Start
State String Activity status, which can be Fail or Success
Code String Error code. An error code is returned if the activity status is Fail.
Message String Error message. An error message is returned if the activity status is Fail.
MediaWorkflowExecution MediaWorkflowExecution Information of media workflow execution

Sample JSON message body:

  1. {
  2. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  3. "Name": "Act-7",
  4. "Type": "Report",
  5. "State": "Success",
  6. "MediaWorkflowExecution": {
  7. "Name": "ConcurrentSuccess",
  8. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  9. "Input": {
  10. "InputFile": {
  11. "Bucket": "inputfirst",
  12. "Location": "oss-test",
  13. "Object": "mediaWorkflow/ConcurrentSuccess/01.wmv"
  14. },
  15. "UserData":"test"
  16. },
  17. "State": "Success",
  18. "MediaId": "2be491ab4cb6499cd0befe5fcf0cb670",
  19. "ActivityList": [
  20. {
  21. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  22. "Name": "Act-1",
  23. "Type": "Start",
  24. "State": "Success",
  25. "StartTime": "2016-03-15T02: 53: 41Z",
  26. "EndTime": "2016-03-15T02: 53: 41Z"
  27. },
  28. {
  29. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  30. "Name": "Act-2",
  31. "Type": "Transcode",
  32. "JobId": "f34b6d1429dd491faa7a6c1c8f905285",
  33. "State": "Success",
  34. "StartTime": "2016-03-15T02: 53: 43Z",
  35. "EndTime": "2016-03-15T02: 53: 47Z"
  36. },
  37. {
  38. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  39. "Name": "Act-3",
  40. "Type": "Transcode",
  41. "JobId": "888ac3903ecf4898b9d790cf7f1d969e",
  42. "State": "Success",
  43. "StartTime": "2016-03-15T02: 53: 44Z",
  44. "EndTime": "2016-03-15T02: 53: 48Z"
  45. },
  46. {
  47. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  48. "Name": "Act-5",
  49. "Type": "Snapshot",
  50. "JobId": "c14150be33304825a5d67cd5364c35cb",
  51. "State": "Success",
  52. "StartTime": "2016-03-15T02: 53: 44Z",
  53. "EndTime": "2016-03-15T02: 53: 45Z"
  54. },
  55. {
  56. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  57. "Name": "Act-6",
  58. "Type": "Snapshot",
  59. "JobId": "8c30c30ca7324286afda1a9a1b14d03c",
  60. "State": "Success",
  61. "StartTime": "2016-03-15T02: 53: 48Z",
  62. "EndTime": "2016-03-15T02: 53: 49Z"
  63. },
  64. {
  65. "RunId": "8f8aba5a62ab4127ae2add18da20b0f2",
  66. "Name": "Act-7",
  67. "Type": "Report",
  68. "State": "Success",
  69. "StartTime": "2016-03-15T02: 53: 49Z",
  70. "EndTime": "2016-03-15T02: 53: 49Z"
  71. }
  72. ],
  73. "CreationTime": "2016-03-15T02: 53: 39Z"
  74. }
  75. }

Return parameters

Name Type Description
Media Media Media

Example

Request example

  1. http://mts.cn-hangzhou.aliyuncs.com?MediaWorkflowUserData=test&amp;MediaWorkflowId=09bc2f74e39c48dd86597849e2b060f6&amp;FileURL=http%3A%2F%2Fzzzinput-test.oss-cn-hangzhou.aliyuncs.com%2Ftail_comm-33.mp4&amp;<public parameter>

Return example

XML

  1. <AddMediaResponse>
  2. <Media>
  3. <CoverURL>http://zzyoutputbucket.oss-cn-hangzhou.aliyuncs.com/aa9bb3115da54befa74e0bd81a7a9e46%2F0.jpg</CoverURL>
  4. <Format>mov,mp4,m4a,3gp,3g2,mj2</Format>
  5. <PublishState>Published</PublishState>
  6. <Height>1280</Height>
  7. <MediaId>3e6149d5a8c944c09b1a8d2dc3e4ac65</MediaId>
  8. <Title>tail_comm-33.mp4</Title>
  9. <CreationTime>2016-09-20T03:02:40Z</CreationTime>
  10. <RunIdList>
  11. <RunId>adee42a78b1f407184a792b8777efb3c</RunId>
  12. </RunIdList>
  13. <CateId>0</CateId>
  14. <Duration>2.645333</Duration>
  15. <Width>1280</Width>
  16. <Fps>25.0</Fps>
  17. <Bitrate>1148.77</Bitrate>
  18. <Size>379860</Size>
  19. </Media>
  20. <RequestId>13E58723-4746-46A5-900D-B41D425A2A44</RequestId>
  21. </AddMediaResponse>

JSON

  1. {
  2. "Media": {
  3. "CoverURL": "http://zzyoutputbucket.oss-cn-hangzhou.aliyuncs.com/adee42a78b1f407184a792b8777efb3c%2F0.jpg",
  4. "Format": "mov,mp4,m4a,3gp,3g2,mj2",
  5. "PublishState": "Published",
  6. "Height": "1280",
  7. "MediaId": "3e6149d5a8c944c09b1a8d2dc3e4ac65",
  8. "Title": "tail_comm-33.mp4",
  9. "CreationTime": "2016-09-20T03:02:40Z",
  10. "RunIdList": {
  11. "RunId": [
  12. "cbad98d35629470fa05ff393d347fd73"
  13. ]
  14. },
  15. "CateId": 0,
  16. "Duration": "2.645333",
  17. "Width": "1280",
  18. "Fps": "25.0",
  19. "Bitrate": "1148.77",
  20. "Size": "379860"
  21. },
  22. "RequestId": "A29ED91C-84A2-41FE-8F7F-116531A28544"
  23. }
Thank you! We've received your feedback.