This topic describes how to query and update the basic information of a media asset.
Query and update the basic information of a media asset
ApsaraVideo Media Processing (MPS) allows you to query and update the basic information of a media asset by using MPS SDKs or calling API operations. For more information about how to install MPS SDKs for different programming languages, see Install Alibaba Cloud SDK for Java, Install Alibaba Cloud SDK for Python, and Install Alibaba Cloud SDK for PHP. For more information about the sample code, see the following text. For more information about how to call API operations, see the Directly call API operations to query and update the basic information of a media asset section of this topic.
In the following example, MPS SDK for PHP is used.
Use the SDK to call API operations to query and update the basic information of a media asset
Query the basic information of a media asset
MPS allows you to query the basic information of a media asset by using the media ID or Object Storage Service (OSS) URL of the media asset.
Query the basic information of a media asset by using its media ID
NoteFor more information about the parameters, see QueryMediaList.
<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\QueryMediaListRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * We recommend that you set the protocol parameter to HTTPS in a production environment. */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new QueryMediaListRequest([ "mediaIds" => "90accf1a2ccb5c5fbc99****" ]); $response = $client->queryMediaList($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
Query the basic information of a media asset by using its OSS URL
NoteAn OSS URL refers to the URL of a media file in an OSS bucket. Example:
http://example-bucket-****.oss-cn-hangzhou.aliyuncs.com/test/1****.mp4
. For more information about the parameters, see QueryMediaListByURL.<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\QueryMediaListByURLRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * We recommend that you set the protocol parameter to HTTPS in a production environment. */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new QueryMediaListByURLRequest([ "fileURLs" => "http://<bucket name>.oss-cn-shanghai.aliyuncs.com/mps_input/video.mp4" ]); $response = $client->queryMediaListByURL($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
Update the parameters of a media asset
<?php namespace AlibabaCloud\SDK\Sample; use AlibabaCloud\SDK\Mts\V20140618\Mts; use AlibabaCloud\Darabonba\Env\Env; use AlibabaCloud\Tea\Tea; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Console\Console; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Mts\V20140618\Models\UpdateMediaRequest; class Sample { /** * @param string $accessKeyId * @param string $accessKeySecret * @param string $regionId * @return Mts * We recommend that you set the protocol parameter to HTTPS in a production environment. */ public static function createClient($accessKeyId, $accessKeySecret, $regionId){ $config = new Config([]); $config->accessKeyId = $accessKeyId; $config->accessKeySecret = $accessKeySecret; $config->regionId = $regionId; $config->protocol = "HTTP"; return new Mts($config); } /** * @return void */ public static function main(){ $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai'); $request = new UpdateMediaRequest([ "mediaId" => "7ce3a1c225ef0670bc2****", "title" => "Update a media asset for test" ]); $response = $client->updateMedia($request); Console::log(Utils::toJSONString(Tea::merge($response->body))); } } $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php'; if (file_exists($path)) { require_once $path; } Sample::main();
Directly call API operations to query and update the basic information of a media asset
You can directly call API operations in OpenAPI Explorer to query or update the basic information of a media asset.
The following table describes the API operations that are used to query and update the basic information of a media asset.
Feature | Operation |
Query the basic information of a media asset based on its media ID | |
Query the basic information of a media asset based on its OSS URL | Note An OSS URL refers to the URL of a media file in an OSS bucket. Example: |
Update all parameters of a media asset | |
Update a single parameter of a media asset |