You need to enable JavaScript to run this app.
导航
视频剪辑
最近更新时间:2024.09.29 17:41:42首次发布时间:2022.10.28 17:25:20

本文为您提供了服务端 PHP SDK 的视频剪辑模块的接口调用示例。

前提条件

调用接口前,请先完成 SDK 的安装初始化

调用示例

提交异步剪辑任务

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

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

// Create a VOD instance in the specified region.
// $client = Volc\Service\Vod\Vod::getInstance('cn-north-1');
$client = Volc\Service\Vod\Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $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:提交同步剪辑任务

// Code generated by protoc-gen-volcengine-sdk
// source: submitDirectEditTaskAsync
// DO NOT EDIT!
<?php
require('../../vendor/autoload.php');

// Create a VOD instance in the specified region.
// $client = Volc\Service\Vod\Vod::getInstance('cn-north-1');
$client = Volc\Service\Vod\Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $client->setAccessKey('your ak');
// $client->setSecretKey('your sk');

$request = new Volc\Service\Vod\Models\Request\VodSubmitDirectEditTaskSyncRequest();
$request->setUploader("your Uploader");
$request->setApplication("your Application");
$request->setEditParam();


$response = new Volc\Service\Vod\Models\Response\VodSubmitDirectEditTaskSyncResponse();
try {
    $response = $client->submitDirectEditTaskSync($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');

// Create a VOD instance in the specified region.
// $client = Volc\Service\Vod\Vod::getInstance('cn-north-1');
$client = Volc\Service\Vod\Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $client->setAccessKey('your ak');
// $client->setSecretKey('your sk');

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

$response = new Volc\Service\Vod\Models\Response\VodCancelDirectEditTaskResponse();
try {
    $response = $client->cancelDirectEditTask($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');

// Create a VOD instance in the specified region.
// $client = Volc\Service\Vod\Vod::getInstance('cn-north-1');
$client = Volc\Service\Vod\Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $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');

// Create a VOD instance in the specified region.
// $client = Volc\Service\Vod\Vod::getInstance('cn-north-1');
$client = Volc\Service\Vod\Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $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 {
    echo $response->serializeToJsonString(), "\n";

    $res = json_decode($response->serializeToJsonString());
    foreach ($res->Result as $result){
        $result->EditParam = json_decode(base64_decode($result->EditParam));
    }
    echo json_encode($res), "\n";
}