You need to enable JavaScript to run this app.
导航

视频剪辑

最近更新时间2023.10.16 21:07:12

首次发布时间2022.10.28 17:25:20

本文为您提供了服务端 PHP SDK 的视频剪辑模块相关的 API 调用示例。主要包含:提交剪辑任务、查询任务进度、查询任务详情等。

初始化

使用前请先完成初始化

提交剪辑任务

接口请求参数和返回参数详见 OpenAPI:提交剪辑任务

<?php
require('../../vendor/autoload.php');
$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');
$request = new Volc\Service\Vod\Models\Request\VodSubmitDirectEditTaskAsyncRequest();
$request->setUploader("your uploader");
$request->setApplication("VideoTrackToB");
$request->setEditParam("your uploader");
$request->setPriority(0);
$request->setCallbackUri("your CallbackUri");
$request->setCallbackArgs("your CallbackArgs");
$response = new Volc\Service\Vod\Models\Response\VodSubmitDirectEditTaskAsyncResponse();
try {
    $response = $client->submitDirectEditTaskAsync($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(), "\n";
}

查询任务进度

接口请求参数和返回参数详见 OpenAPI:查询任务进度

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodGetDirectEditProgressRequest();
$request->setReqId("your ReqId");


$response = new Volc\Service\Vod\Models\Response\VodGetDirectEditProgressResponse();
try {
    $response = $client->getDirectEditProgress($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    echo $response->serializeToJsonString(),"\n";
}

查询任务详情

接口请求参数和返回参数详见 OpenAPI:查询任务详情

<?php
require('../../vendor/autoload.php');

$client = Volc\Service\Vod\Vod::getInstance();
$client->setAccessKey('your ak');
$client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodGetDirectEditResultRequest();
$request->setReqIds(['your ReqId1','your ReqId2']);

$response = new Volc\Service\Vod\Models\Response\VodGetDirectEditResultResponse();
try {
    $response = $client->getDirectEditResult($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) {
    echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n";
} else {
    foreach ($response->getResult() as $elem) {
        // 如果需要访问 Track字段,则使用下列循环和  vector 取出数据;
        // 如不需使用 Track 参数的话,则使用默认的 xxx->getYYY()取参数即可
        $editParam = json_decode($elem->getEditParam()->serializeToJsonString(),true);
        foreach($editParam['Track'] as $tracks) {
            foreach($tracks as $track){
                echo $track['ID'],"\n";
                echo $track['Source'],"\n";
                foreach ($track['TargetTime'] as $targetTime) {
                    echo $targetTime,"\n";
                }
                echo $track['Type'],"\n";
            }
        }
    }
    echo $response->serializeToJsonString(), "\n";
}