The micro-drama solution provides capabilities to manage media through APIs. This topic describes the basic API operations for micro-drama media management.
Before using micro-drama media management, make sure that you understand the basics of media asset management. For more information, see Overview of media asset management.
Media asset search
Overview
You can call the SearchMedia operation to search for media assets such as videos, audio files, and images that are produced in ApsaraVideo VOD. You can specify return fields, use exact match, fuzzy match, multi-value query, range query, and sort fields to perform multi-dimensional searches in ApsaraVideo VOD.
Interface description
The maximum number of data records that you can query is limited based on the method used to query the data. You can use the following methods to query data:
Method 1: Traverse data by page
You can use the PageNo and PageSize parameters to traverse up to 5,000 data records that meet the specified filter condition. PageNo specifies the page number and PageSize specifies the number of data records displayed on a page. If the number of data records that meet the specified filter condition exceeds 5,000, change the filter conditions to narrow down the results. You cannot use this method to traverse all data records. If you want to traverse more data records, use Method 2.
Method 2: Traverse all data (available only for audio and video files)
You can use this method to traverse up to 2 million data records related to audio and video files. If the number of data records that meet the specified filter condition exceeds 2 million, change the filter conditions to narrow down the results. To traverse data page by page, you must set the PageNo, PageSize, and ScrollToken parameters. The total number of data records from the current page to the target page cannot exceed 100. For example, if you set PageSize to 20, the traverse logic works as follows:
When the PageNo parameter is set to 1, you can traverse data records from page 1 to page 5.
When the PageNo parameter is set to 2, you can traverse data records from page 2 to page 6.
Make sure that you set the appropriate page number and page size, and use a traverse method based on the number of results that meet your filter condition.
Example
The following sample code shows how to call the SearchMedia operation:
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* <b>description</b> :
* <p>Use your AccessKey pair to initialize the client.</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.vod20170321.Client createClient() throws Exception {
// If the project code is leaked, the AccessKey pair may be leaked and security issues may occur in all resources that belong to your Alibaba Cloud account. The following sample code is provided for reference only.
// For security purposes, we recommend that you use temporary access credentials that are provided by Security Token Service (STS). For more information, see https://www.alibabacloud.com/help/en/sdk/developer-reference/v2-manage-access-credentials.
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is configured.
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
// Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is configured.
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
// For more information about endpoints, see https://api.aliyun.com/product/vod.
config.endpoint = "vod.cn-shanghai.aliyuncs.com";
return new com.aliyun.vod20170321.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.vod20170321.Client client = Sample.createClient();
com.aliyun.vod20170321.models.SearchMediaRequest searchMediaRequest = new com.aliyun.vod20170321.models.SearchMediaRequest();
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// Run the code you write to print the response of the API operation if necessary.
client.searchMediaWithOptions(searchMediaRequest, runtime);
} catch (TeaException error) {
// Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided only for reference.
// Return error messages.
System.out.println(error.getMessage());
// Provide the URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided only for reference.
// Return error messages.
System.out.println(error.getMessage());
// Provide the URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}Obtain information about a single audio or video file
Overview
Queries information about a single audio or video file based on its ID, including title, description, duration, thumbnail URL, status, creation time, size, snapshots, category, and tags.
Interface description
After a media file is uploaded, ApsaraVideo VOD processes the source file. Information about the media file is then asynchronously generated. You can configure event notifications for the completion of media file analysis. After you receive the notification, you can call this operation to obtain information about the media file.
Example
The following sample code shows how to call the GetVideoInfo operation:
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* <b>description</b> :
* <p>Use your AccessKey pair to initialize the client.</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.vod20170321.Client createClient() throws Exception {
// If the project code is leaked, the AccessKey pair may be leaked and security issues may occur in all resources that belong to your Alibaba Cloud account. The following sample code is provided for reference only.
// For security purposes, we recommend that you use temporary access credentials that are provided by Security Token Service (STS). For more information, see https://www.alibabacloud.com/help/en/sdk/developer-reference/v2-manage-access-credentials.
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is configured.
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
// Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is configured.
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
// For more information about endpoints, see https://api.aliyun.com/product/vod.
config.endpoint = "vod.cn-shanghai.aliyuncs.com";
return new com.aliyun.vod20170321.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.vod20170321.Client client = Sample.createClient();
com.aliyun.vod20170321.models.GetVideoInfoRequest getVideoInfoRequest = new com.aliyun.vod20170321.models.GetVideoInfoRequest();
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// Run the code you write to print the response of the API operation if necessary.
client.getVideoInfoWithOptions(getVideoInfoRequest, runtime);
} catch (TeaException error) {
// Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided only for reference.
// Return error messages.
System.out.println(error.getMessage());
// Provide the URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided only for reference.
// Return error messages.
System.out.println(error.getMessage());
// Provide the URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}Obtain information about multiple audio or video files
Interface description
You can call the GetVideoList operation to obtain information about up to 5000 audio or video files that meet the specified filter conditions, such as the status and category ID. We recommend that you set the StartTime and EndTime parameters to narrow down the time range and perform multiple queries to obtain data. If you want to query more audio or video files or traverse all audio or video files, see media asset search.
Example
The following sample code shows how to call the GetVideoList operation:
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* <b>description</b> :
* <p>Use your AccessKey pair to initialize the client.</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.vod20170321.Client createClient() throws Exception {
// If the project code is leaked, the AccessKey pair may be leaked and security issues may occur in all resources that belong to your Alibaba Cloud account. The following sample code is provided for reference only.
// For security purposes, we recommend that you use temporary access credentials that are provided by Security Token Service (STS). For more information, see https://www.alibabacloud.com/help/en/sdk/developer-reference/v2-manage-access-credentials.
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is configured.
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
// Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is configured.
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
// For more information about endpoints, see https://api.aliyun.com/product/vod.
config.endpoint = "vod.cn-shanghai.aliyuncs.com";
return new com.aliyun.vod20170321.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.vod20170321.Client client = Sample.createClient();
com.aliyun.vod20170321.models.GetVideoListRequest getVideoListRequest = new com.aliyun.vod20170321.models.GetVideoListRequest();
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// Run the code you write to print the response of the API operation if necessary.
client.getVideoListWithOptions(getVideoListRequest, runtime);
} catch (TeaException error) {
// Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided only for reference.
// Return error messages.
System.out.println(error.getMessage());
// Provide the URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided only for reference.
// Return error messages.
System.out.println(error.getMessage());
// Provide the URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}FAQ
How do I delete a stream with a specific definition?
Call the GetPlayInfo operation to obtain the stream ID (JobId) that you want to delete. Then, call the DeleteStream operation to delete the stream.
How do I delete legacy streams after retranscoding?
After retranscoding, legacy stream files are retained to ensure smooth playback switching between new and legacy output streams. By default, the GetPlayInfo operation returns only the latest transcoded stream in each definition and format to ensure that the latest transcoded stream is played each time. When you call the GetPlayInfo operation, you can set the
ResultTypeparameter to Multiple to obtain all transcoded streams of the audio or video file. You can identify legacy streams based on the creation time, obtain their IDs, and delete them.How do I delete encrypted streams?
To ensure the security of stream information, the GetPlayInfo operation returns only non-encrypted streams by default. When you call the GetPlayInfo operation, you can set the
ResultTypeparameter to Multiple to obtain all transcoded streams of the audio or video file. You can identify encrypted streams based on theEncryptfield in the basic data type struct, obtain their IDs, and delete them.