云剪辑工程管理

通过阅读本文,您可以了解通过服务端SDK调用OpenAPI管理智能媒体服务云剪辑工程的示例代码。

注意事项

创建云剪辑工程时,Title为必选参数;如果要调用 SubmitMediaProducingJob提交剪辑合成作业,参数Timeline必须设置。

示例代码

您可以通过阿里云OpenAPI开发者门户在线调试。

<?php

require_once '../vendor/autoload.php';

use AlibabaCloud\SDK\ICE\V20201109\ICE;
use AlibabaCloud\SDK\ICE\V20201109\Models;
use AlibabaCloud\SDK\ICE\V20201109\Models\SearchEditingProjectRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\CreateEditingProjectRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\GetEditingProjectRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\UpdateEditingProjectRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\DeleteEditingProjectsRequest;
use Darabonba\OpenApi\Models\Config;

try {

    // 阿里云账号AccessKey拥有所有API的访问权限,建议您使用RAM用户进行API访问或日常运维。
    // 本示例以将AccessKey ID和 AccessKey Secret保存在环境变量为例说明。配置方法请参见:https://help.aliyun.com/document_detail/311677.html
    $credential = new Credential([]);
    $config = new Config([
     'credential' => $credential,
     'endpoint' => 'ice.cn-shanghai.aliyuncs.com'
    ]);
    // 如需硬编码AccessKey ID和AccessKey Secret,代码如下,但强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。
    // $config->accessKeyId = '<yourAccessKeyId>';
    // $config->accessKeySecret = '<yourAccessKeySecret>';
    $client = new ICE($config);

    // 搜索云剪辑工程
    $request = new SearchEditingProjectRequest();
    $response = $client->searchEditingProject($request);
    var_dump($response);

    // 创建云剪辑工程
    $request = new CreateEditingProjectRequest();
    $request->title = "测试工程名字";
    $request->description = "测试工程描述";
    $request->timeline = "{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"}]}]}";
    $request->coverURL = "http://xxxx/coverUrl.jpg";
    $response = $client->createEditingProject($request);
    $projectId = $response->body->project->projectId;
    var_dump($response);

    // 获取单个云剪辑工程
    $request = new GetEditingProjectRequest();
    $request->projectId = $projectId;
    $response = $client->getEditingProject($request);
    var_dump($response);

    // 修改云剪辑工程
    $request = new UpdateEditingProjectRequest();
    $request->projectId = $projectId;
    $request->timeline = "{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"}]}]}";
    $response = $client->updateEditingProject($request);
    var_dump($response);

    // 删除云剪辑工程
    $request = new DeleteEditingProjectsRequest();
    $request->projectIds = $projectId;
    $response = $client->deleteEditingProjects($request);
    var_dump($response);

} catch (TeaUnableRetryError $e) {
    var_dump($e->getMessage());
    var_dump($e->getErrorInfo());
    var_dump($e->getLastException());
    var_dump($e->getLastRequest());
}

相关接口