You need to enable JavaScript to run this app.
文档中心
视频点播

视频点播

复制全文
下载 pdf
PHP SDK
媒体处理
复制全文
下载 pdf
媒体处理

本文为您提供了服务端 PHP SDK 的媒体处理模块的接口调用示例。

前提条件

调用接口前,请先完成集成 PHP SDK。

调用示例

触发工作流

接口请求参数和返回参数详见 OpenAPI:触发工作流。
示例中的 your Vid / your vid 和 your TemplateId / your template id 均为占位值,请分别替换为视频点播控制台中的视频 Vid 和工作流模板 ID。请先创建工作流模板,并确保它与视频所在空间匹配。 将需要运行的单个示例保存为 PHP 文件,按项目目录调整 vendor/autoload.php 路径,配置凭证后在终端执行 php <脚本文件名>.php。

<?php
// Code generated by protoc-gen-volcengine-sdk
// source: startWorkflow
// DO NOT EDIT!
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\VodStartWorkflowRequest();
// 视频 ID
$request->setVid("your Vid");
// 工作流 ID
$request->setTemplateId("your TemplateId");
$request->setInput(new Volc\Service\Vod\Models\Business\WorkflowParams());
$request->setPriority(0);
$request->setCallbackArgs("your CallbackArgs");
$request->setEnableLowPriority(false);
// $request->setDirectUrl(new Volc\Service\Vod\Models\Business\DirectUrl());
$request->setTaskListId("your TaskListId");
$request->setClientToken("your ClientToken");


$response = new Volc\Service\Vod\Models\Response\VodStartWorkflowResponse();
try {
    $response = $client->startWorkflow($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\VodRetrieveTranscodeResultRequest();
$request->setVid("your Vid");
$request->setResultType("your ResultType");


$response = new Volc\Service\Vod\Models\Response\VodRetrieveTranscodeResultResponse();
try {
    $response = $client->retrieveTranscodeResult($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\VodGetWorkflowExecutionStatusRequest();
$request->setRunId("your RunId");

$response = new Volc\Service\Vod\Models\Response\VodGetWorkflowExecutionStatusResponse();
try {
    $response = $client->GetWorkflowExecution($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\VodGetWorkflowResultRequest();
$request->setRunId("your RunId");


$response = new Volc\Service\Vod\Models\Response\VodGetWorkflowResultResponse();
try {
    $response = $client->GetWorkflowExecutionResult($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\VodGetAdAuditResultByVidRequest();
$request->setSpaceName("your SpaceName");
$request->setVid("your Vid");
$request->setFileIds(["your FileIds"]);


$response = new Volc\Service\Vod\Models\Response\VodGetAdAuditResultByVidResponse();
try {
    $response = $client->getAdAuditResultByVid($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";
}
最近更新时间:2026.10.27 16:18:33
这个页面对您有帮助吗?
有用
有用
无用
无用