This topic describes the sample code that is used to call API operations by using the server SDK to create an editing and production job in Intelligent Media Services (IMS).
Usage notes
You can create a production job by using Timeline, TemplateId, or ProjectId based on your business requirements.
Sample code
You can use Alibaba Cloud OpenAPI Explorer to perform online debugging.
<?php
require_once '../vendor/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 {
// An AccessKey pair of an Alibaba Cloud account has access permissions on all API operations. We recommend that you use an AccessKey pair of a RAM user to call API operations or perform routine O&M.
// In this example, the AccessKey ID and the AccessKey secret are obtained from the environment variables. For more information, visit https://www.alibabacloud.com/help/en/sdk/developer-reference/v2-manage-php-access-credentials?spm=a2c63.p38356.help-menu-262060.d_1_6_1_3.44a91156YPuudN.
$credential = new Credential([]);
$config = new Config([
'credential' => $credential,
'endpoint' => 'ice.cn-shanghai.aliyuncs.com'
]);
// To hard-code your AccessKey ID and AccessKey secret, use the following code. However, we recommend that you do not save the AccessKey ID and the AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of resources within your account may be compromised.
// $config->accessKeyId = '<yourAccessKeyId>';
// $config->accessKeySecret = '<yourAccessKeySecret>';
$client = new ICE($config);
// Create a production job by using a 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;
// Create a production job by using a template.
$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;
// Create a production job by using a project.
$request = new SubmitMediaProducingJobRequest();
$request->projectId = "****9b4d7cf14dc7b83b0e801cbe****";
$request->outputMediaConfig = "{\"mediaURL\":\"https://***sample.aliyuncs.com/ice/***\"}";
$response = $client->submitMediaProducingJob($request);
var_dump($response);
// Obtain a single production job.
$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());
}