Registers a media file.

Usage notes

After you store an audio or video file in an Object Storage Service (OSS) bucket that is used for ApsaraVideo VOD, you can call the RegisterMedia operation to register the media file. After the media file is registered, you can use the media ID associated with the media file to submit transcoding jobs and snapshot jobs in ApsaraVideo VOD. For more information, see SubmitTranscodeJobs and SubmitSnapshotJob.

Note
  • You can register up to 10 OSS media files that have the same storage location at a time.
  • If you use the ApsaraVideo VOD console to upload a media file and do not specify a transcoding template group ID, ApsaraVideo VOD uses the default transcoding template group to transcode the media file. However, if you do not specify a transcoding template group ID when you call the RegisterMedia operation, ApsaraVideo VOD does not automatically transcode the media file after the media file is registered. If you specify a transcoding template group ID, ApsaraVideo VOD uses the specified transcoding template group to transcode the media file.
  • If the media file that you want to register is registered before, this operation returns only the unique media ID that is associated with the media file. No further processing is performed.

QPS limit

You can call this operation up to 50 times per second per account. 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 on API operations in ApsaraVideo VOD.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes RegisterMedia

The operation that you want to perform. Set the value to RegisterMedia.

RegisterMetadatas String Yes [{"FileURL":"https://****.oss-cn-shanghai.aliyuncs.com/video/test/video123.m3u8","Title":"VideoName"}]

The metadata of the media file that you want to register. The value is a JSON string. You can specify the metadata for a maximum of 10 media files at a time. For more information about the metadata of media files, see the RegisterMetadata section of this topic.

TemplateGroupId String No ca3a8f6e49c87b65806709586****

The ID of the transcoding template group. You can use one of the following methods to obtain the ID of the transcoding template group:

  • Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Processing > Transcoding Template Groups. On the Transcoding Template Groups page, you can view the ID of the transcoding template group.
  • View the value of the TranscodeTemplateGroupId parameter returned by the AddTranscodeTemplateGroup operation that you called to create a transcoding template group.
  • View the value of the TranscodeTemplateGroupId parameter returned by the ListTranscodeTemplateGroup operation that you called to query a transcoding template group.
Note
  • If you do not need to transcode the media file, set the TemplateGroupId parameter to VOD_NO_TRANSCODE. Otherwise, an exception occurs during video playback. If you need to transcode the media file, specify the ID of the transcoding template group.
  • If both the WorkflowId and TemplateGroupId parameters are set, the value of the WorkflowId parameter takes effect. For more information, see Workflows.
UserData String No null

The custom configurations such as callback configurations. The value is a JSON string. For more information, see the "UserData: specifies the custom configurations for media upload" section of the Request parameters topic.

WorkflowId String No 637adc2b7ba51a83d841606f8****

The ID of the workflow. To view the ID of the workflow, log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Processing > Workflows.

Note If both the WorkflowId and TemplateGroupId parameters are set, the value of the WorkflowId parameter takes effect. For more information, see Workflows.

RegisterMetadata

The following table describes the metadata of the media file that you want to register.

Parameter

Type

Required

Description

FileURL

String

Yes

The OSS URL of the source file. You can call the GetMezzanineInfo operation to obtain the OSS URL of the source file.

The URL can be up to 1,024 bytes in length. The file name must be globally unique. If the media file that you want to register is registered before, the unique media ID that is associated with the media file is returned.

Title

String

Yes

The title of the media file. The title can be up to 128 bytes in length. The value must be encoded in UTF-8.

Description

String

No

The description of the media file. The description can be up to 1,024 bytes in length. The value must be encoded in UTF-8.

Tags

String

No

The one or more tags of the media file. Each tag can be up to 32 bytes in length. You can specify a maximum of 16 tags. Separate multiple tags with commas (,). The value must be encoded in UTF-8.

CoverURL

String

No

The URL of the thumbnail. The URL can be up to 1,024 bytes in length.

CateId

Long

No

The category ID of the media file. You can use one of the following methods to obtain the category ID:

Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Management > Categories. On the Categories page, you can view the category ID of the media file.

View the value of the CateId parameter returned by the AddCategory operation that you called to create a category.

View the value of the CateId parameter returned by the GetCategories operation that you called to query a category.

Response parameters

Parameter Type Example Description
RequestId String 14F43C5C-8033-448B-AD04F64E5098****

The ID of the request.

FailedFileURLs Array of String ["http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_03.mp4"]

The URLs of the media files that failed to be registered.

RegisteredMediaList Array of RegisteredMedia

The media files that are registered, including newly registered and repeatedly registered media files.

NewRegister Boolean false

Indicates whether the media file is newly registered or repeatedly registered. Valid values:

  • true: The media file is newly registered.
  • false: The media file is repeatedly registered.
FileURL String http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_01.mp4

The OSS URL of the media file.

MediaId String d97af32828084d1896683b1aa38****

The ID of the media file that is registered with ApsaraVideo VOD. If the registered media file is an audio or video file, the value of the VideoId parameter returned by ApsaraVideo VOD takes effect.

Examples

Sample requests

http(s)://vod.cn-shanghai.aliyuncs.com/?Action=RegisterMedia
&RegisterMetadatas=[{"FileURL":"https://****.oss-cn-shanghai.aliyuncs.com/video/test/video123.m3u8","Title":"VideoName"}]
&UserData={"Extend":{"localId":"****","test":"www"}}
&WorkflowId=637adc2b7ba51a83d841606f8****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<RegisterMediaResponse>
    <RequestId>14F43C5C-8033-43E7-B48B-AD04F64E5098</RequestId>
    <RegisteredMediaList>
        <MediaId>d97af328280842229aed1896683b1aa38</MediaId>
        <FileURL>http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_01.mp4</FileURL>
        <NewRegister>true</NewRegister>
    </RegisteredMediaList>
    <RegisteredMediaList>
        <MediaId>d97af328280842229aed1896683b1aa38</MediaId>
        <FileURL>http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_02.mp4</FileURL>
        <NewRegister>false</NewRegister>
    </RegisteredMediaList>
    <FailedFileURLs>http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_03.mp4</FailedFileURLs>
</RegisterMediaResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "14F43C5C-8033-43E7-B48B-AD04F64E5098",
  "RegisteredMediaList" : [ {
    "MediaId" : "d97af328280842229aed1896683b1aa38",
    "FileURL" : "http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_01.mp4",
    "NewRegister" : true
  }, {
    "MediaId" : "d97af328280842229aed1896683b1aa38",
    "FileURL" : "http://*****.oss-cn-shanghai.aliyuncs.com/vod_sample_02.mp4",
    "NewRegister" : false
  } ],
  "FailedFileURLs" : [ "http://****.oss-cn-shanghai.aliyuncs.com/vod_sample_03.mp4" ]
}

Error codes

For a list of error codes, visit the API Error Center.