日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

新增媒體工作流

更新時(shí)間:

如果需要制作多碼率、多音軌、多字幕或多格式等類型視頻,或希望預(yù)先編排好一系列任務(wù)流程,然后按照編排好的環(huán)節(jié)和條件依次執(zhí)行任務(wù),您可以創(chuàng)建工作流并在工作流中設(shè)置轉(zhuǎn)碼、分析、截圖、打包(封裝)、審核、提取視頻DNA、設(shè)置智能封面等任務(wù)節(jié)點(diǎn)。本文介紹媒體處理PHP SDK新增媒體工作流的示例代碼。

前提條件

使用前請(qǐng)先安裝及完成PHP SDK相關(guān)配置,詳細(xì)信息,請(qǐng)參見前言。更多SDK及API調(diào)用示例,請(qǐng)參見OpenAPI

新增媒體工作流

調(diào)用AddMediaWorkflow新增媒體工作流,接口參數(shù)和返回字段詳細(xì)信息請(qǐng)參見新增媒體工作流,調(diào)用示例如下:

<?php
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Mts\V20140618\Mts;
use AlibabaCloud\Darabonba\Env\Env;
use AlibabaCloud\Tea\Tea;
use AlibabaCloud\Tea\Utils\Utils;
use AlibabaCloud\Tea\Console\Console;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Mts\V20140618\Models\AddMediaWorkflowRequest;


class Sample {

    private $region = '<region>';
    private $pipelineId = "<PipelineId>";
    private $templateId = "S00000001-100020"; #轉(zhuǎn)碼模板ID,m3u8模板,按需配置
    private $ossLocation = "<OssLocation>";
    private $inputBucket = "<InputBucket>";
    private $inputPath = "<InputPath>"; 
    private $outputBucket = "<OutputBucket>";
    private $actStart = "Act-Start";
    private $actTransCode = "Act-TransCode";
    private $actReport = "Act-Report";

    /**
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @param string $regionId
     * @return Mts
     * 正式環(huán)境下 建議 protocol = "HTTPS";
     */
    public static function createClient($accessKeyId, $accessKeySecret, $regionId){
        $config = new Config([]);
        $config->accessKeyId = $accessKeyId;
        $config->accessKeySecret = $accessKeySecret;
        $config->regionId = $regionId;
        $config->protocol = "HTTP";
        return new Mts($config);
    }

    /**
     * @return void
     * includePlayList  返回結(jié)果中是否包含播放信息
     * includeSnapshotList  返回結(jié)果中是否包含截圖信息
     * includeMediaInfo  返回結(jié)果中是否包含媒體信息
     * includeSummaryList   返回結(jié)果中是否包含摘要
     */
    public static function main(){
        $sample = new Sample;
        $client = self::createClient(Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_ID"), Env::getEnv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), 'cn-shanghai');
        $request = new AddMediaWorkflowRequest([
            "name" => "轉(zhuǎn)碼工作流",
            "topology" => $sample->buildWorkflowTopology()
        ]);
        $response = $client->addMediaWorkflow($request);
        Console::log(Utils::toJSONString(Tea::merge($response->body)));
    }
    function buildWorkflowTopology() {
        $activities = $this->buildActivities();
        $dependencies = $this->buildDependencies();
        $workflow = array(
                          "Activities" => $activities,
                          "Dependencies" => $dependencies
                         );
        echo json_encode($workflow)."\n";
        return json_encode($workflow);
    }

    function buildActivities() {
        $activities = [
            $this->actStart => $this->buildStartActivity(),
            $this->actTransCode => $this->buildTranscodeActivity(),
            $this->actReport => $this->buildReportActivity()
        ];
        return $activities;
    }

    /**
     * start節(jié)點(diǎn)
     */

    function buildStartActivity() {
        $startActivity = array(
            "Name" => $this->actStart,
            "Type" => "Start",
            "Parameters" => $this->buildStartParameters()
        );
        return $startActivity;
    }
    
    function buildStartParameters() {
        $startParameters = array(
            "PipelineId" => $this->pipelineId,
            "InputFile" => $this->buildInputFile()
        );
        return $startParameters;
    }
    /**
     * 觸發(fā)路徑
     */
    function buildInputFile() {
        $inputFile = array(
            "Bucket" => $this->inputBucket,
            "Location" => $this->ossLocation,
            "ObjectPrefix" => $this->inputPath
        );
        return $inputFile;
    }

    /**
     * 轉(zhuǎn)碼配置
     */
    function buildTranscodeActivity() {
        $transcodeParameters = array(
            "Name" => $this->actTransCode,
            "Type" => "Transcode",
            "Parameters" => $this->buildTranscodeParameters()
        );
        return $transcodeParameters;
    }

    function buildTranscodeParameters() {
        $transcodeParameters = array(
            "OutputBucket" => $this->outputBucket,
            "OutputLocation" => $this->ossLocation,
            "Outputs" => $this->buildOutputsConfig()
        );
        return $transcodeParameters;
    }

    /**
     * 輸出配置
     */
    function buildOutputsConfig() {
        $output = array(
            "ObjectRegex" => $this->actTranscCode."/{RunId}/{FileName}",
            "TemplateId" => $this->templateId
        );
        $outputs = array($output);
        return $outputs;
    }
    /**
     * Report節(jié)點(diǎn)
     */
    private $reportActivity = array(
        "Type"=> "Report",
        "Parameters"=> array(
             "PublishType"=>"Auto"
        )
    );
    /**
     * 構(gòu)建Activity節(jié)點(diǎn)
     */
    function buildReportActivity() {
        $reportActivity = array(
            "Name" => $this->actReport,
            "Parameters" => (object)[],
            "Type" => "Report"
        );
        return $reportActivity;
    }
    /**
     * 構(gòu)建依賴關(guān)系
     */
    function buildDependencies() {
        $subActivityOfStart = array(
            $this->actTransCode
        );
        $subActivityOfTranscode = array(
            $this->actReport
        );
        $dependencies = array(
            $this->actStart => $subActivityOfStart,
            $this->actTransCode => $subActivityOfTranscode,
            $this->actReport => []
        );
        return $dependencies;
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main();

相關(guān)文檔