ltworkflow php_新增媒体工作流_PHP SDK_媒体转码SDK_SDK参考_媒体处理 - 阿里云

唐星晖
2023-12-01

新增媒体工作流,您可以对MPS服务提供的活动(例如,转码、截图等活动)进行组装,拓扑结构如下。

include_once 'aliyun-openapi-php-sdk/aliyun-php-sdk-core/Config.php';

use Mts\Request\V20140618 as Mts;

# Step 1 set region

$REGION = "cn-shenzhen";

$OSS_REGION = "oss-cn-shenzhen";

$mtsEndpoint = "mts." + REGION + ".aliyuncs.com";

# Step 2.set accesskey & keySecret

$accessKeyId = "";

$accessKeySecret = "";

# Step 3.set mps transcoding queue id

$PIPELINE_ID = "38bba54d524448be92d277caaa8da118";

# 创建DefaultAcsClient实例并初始化

$clientProfile = DefaultProfile::getProfile(

$REGION, # 您的 Region ID

$accessKeyId, # 您的 AccessKey ID

$accessKeySecret # 您的 AccessKey Secret

);

$client = new DefaultAcsClient($clientProfile);

$request = new Mts\AddMediaWorkflowRequest();

$request->setAcceptFormat('JSON');

$request->setName("Sequential-workflow");

$startActivity = array(

"Type"=>"Start",

"Parameters"=>array(

"InputFile"=>array(

"Bucket"=> "mtb-sz-in",

"Location"=> $OSS_REGION,

"ObjectPrefix"=> "media/"

),

"PipelineId"=>$PIPELINE_ID

)

);

$transcodeActivity = array(

"Type"=>"Transcode",

"Parameters"=> array (

"Outputs"=>array(

array(

"OutputObject"=> urlencode("transcode/{ObjectPrefix}/{FileName}.{ExtName}"),

"TemplateId"=> "S00000001-000070"

)

),

"OutputLocation"=> $OSS_REGION,

"OutputBucket"=>"mtb-sz-out"

)

);

$reportActivity = array(

"Type"=> "Report",

"Parameters"=> array(

"PublishType"=>"Auto"

)

);

$topology = array(

"Activities"=> array(

"startNode"=>$startActivity,

"transcodingNode"=>$transcodeActivity,

"reportNode"=>$reportActivity

),

"Dependencies"=>array (

"startNode"=>array("transcodingNode"),

"transcodingNode"=>array("reportNode"),

"reportNode"=>array()

)

);

$request->setTopology(json_encode($topology));

# 发起请求并处理返回

try {

$response = $client->getAcsResponse($request);

print 'RequestId is:' . $response->{'RequestId'} . "\n";;

print "Response:".json_encode($response);

} catch(ServerException $e) {

print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";

} catch(ClientException $e) {

print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";

}

?>

 类似资料: