edit-icon download-icon

Add media workflow

Last Updated: Mar 28, 2018

The user can assemble activities provided by MPS, such as transcode activity and screenshot activity into a topology. The topology is as follows:

  1. <?php
  2. include_once 'aliyun-openapi-php-sdk/aliyun-php-sdk-core/Config.php';
  3. use Mts\Request\V20140618 as Mts;
  4. # Step 1 set region
  5. $REGION = "cn-shenzhen";
  6. $OSS_REGION = "oss-cn-shenzhen";
  7. $mtsEndpoint = "mts." + REGION + ".aliyuncs.com";
  8. # Step 2.set accesskey & keySecret
  9. $accessKeyId = "";
  10. $accessKeySecret = "";
  11. # Step 3.set mps transcoding queue id
  12. $PIPELINE_ID = "38bba54d524448be92d277caaa8da118";
  13. # Create DefaultAcsClient instance and perform initialization
  14. $clientProfile = DefaultProfile::getProfile(
  15. $REGION, # Your Region ID
  16. $accessKeyId, # Your AccessKey ID
  17. $accessKeySecret # Your AccessKey Secret
  18. );
  19. $client = new DefaultAcsClient($clientProfile);
  20. $request = new Mts\AddMediaWorkflowRequest();
  21. $request->setAcceptFormat('JSON');
  22. $request->setName("Sequential-workflow");
  23. $startActivity = array(
  24. "Type"=>"Start",
  25. "Parameters"=>array(
  26. "InputFile"=>array(
  27. "Bucket"=> "mtb-sz-in",
  28. "Location"=> $OSS_REGION,
  29. "ObjectPrefix"=> "media/"
  30. ),
  31. "PipelineId"=>$PIPELINE_ID
  32. )
  33. );
  34. $transcodeActivity = array(
  35. "Type"=>"Transcode",
  36. "Parameters"=> array (
  37. "Outputs"=>array(
  38. array(
  39. "OutputObject"=> urlencode("transcode/{ObjectPrefix}/{FileName}.{ExtName}"),
  40. "TemplateId"=> "S00000001-000070"
  41. )
  42. ),
  43. "OutputLocation"=> $OSS_REGION,
  44. "OutputBucket"=>"mtb-sz-out"
  45. )
  46. );
  47. $reportActivity = array(
  48. "Type"=> "Report",
  49. "Parameters"=> array(
  50. "PublishType"=>"Auto"
  51. )
  52. );
  53. $topology = array(
  54. "Activities"=> array(
  55. "startNode"=>$startActivity,
  56. "transcodingNode"=>$transcodeActivity,
  57. "reportNode"=>$reportActivity
  58. ),
  59. "Dependencies"=>array (
  60. "startNode"=>array("transcodingNode"),
  61. "transcodingNode"=>array("reportNode"),
  62. "reportNode"=>array()
  63. )
  64. );
  65. $request->setTopology(json_encode($topology));
  66. # Initiate request and handle returned result
  67. try {
  68. $response = $client->getAcsResponse($request);
  69. print 'RequestId is:' . $response->{'RequestId'} . "\n";;
  70. print "Response:".json_encode($response);
  71. } catch(ServerException $e) {
  72. print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
  73. } catch(ClientException $e) {
  74. print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
  75. }
  76. ?>
Thank you! We've received your feedback.