全部产品

剪辑合成

本文介绍如何通过ICE PHP SDK创建合成任务。

创建合成任务

创建合成任务有三种方式:

1、通过时间线创建

2、通过模板创建

3、通过project创建

以上三种方式任选其一

获取单个合成任务

通过GetMediaProducingJob接口获取合成任务的输入、输出及状态。

代码示例

<?php

require_once '../ice-20201109/autoload.php';

use AlibabaCloud\SDK\ICE\V20201109\ICE;
use AlibabaCloud\SDK\ICE\V20201109\Models;
use AlibabaCloud\SDK\ICE\V20201109\Models\SubmitMediaProducingJobRequest;
use AlibabaCloud\SDK\ICE\V20201109\Models\GetMediaProducingJobRequest;
use Darabonba\OpenApi\Models\Config;

try {

 $config = new Config();
 $config->accessKeyId = "<yourAccessKeyId>";
 $config->accessKeySecret = "<yourAccessKeySecret>";
 $config->regionId = "cn-shanghai";
 $config->endpoint = "ice.cn-shanghai.aliyuncs.com";
 $client = new ICE($config);

    // 通过timeline创建合成任务
    $request = new SubmitMediaProducingJobRequest();
    $request->timeline = "{\"VideoTracks\":[{\"VideoTrackClips\":[{\"MediaId\":\"****9b4d7cf14dc7b83b0e801cbe****\"},{\"MediaId\":\"****b4d7cf14dc7b83b0e801cbe****\"}]}]}";
    $request->projectMetadata = "{\"coverURL\":\"http://***sample.test.com/media/cover/mediaid.jpg\",\"description\":\"description\",\"title\":\"title\",\"tags\":\"Tag1,Tag2,Test\"}";
    $request->outputMediaConfig = "{\"mediaURL\":\"https://***sample.aliyuncs.com/ice/***\"}";
    $response = $client->submitMediaProducingJob($request);
    var_dump($response);
    $jobId = $response->body->jobId;

    // 通过模板创建合成任务
    $request = new SubmitMediaProducingJobRequest();
    $request->templateId = "IceSys_VideoMerge";
    $request->clipsParam = "{\"VideoArray\":[\"****as05512043f49f697f7425as****\",\"****as2788e810116a45109f2efd****\",\"****sd67f44f4964e6c998dee8df****\",]}";
    $request->outputMediaConfig = "{\"mediaURL\":\"https://***sample.aliyuncs.com/ice/***\"}";
    $response = $client->submitMediaProducingJob($request);
    var_dump($response);
    $jobId = $response->body->jobId;

    // 通过project创建合成任务
    $request = new SubmitMediaProducingJobRequest();
    $request->projectId = "****9b4d7cf14dc7b83b0e801cbe****";
    $request->outputMediaConfig = "{\"mediaURL\":\"https://***sample.aliyuncs.com/ice/***\"}";
    $response = $client->submitMediaProducingJob($request);
    var_dump($response);

    // 获取单个合成任务
    $request = new GetMediaProducingJobRequest();
    $request->jobId = $jobId;
    $response = $client->getMediaProducingJob($request);
    var_dump($response);

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