createMediaConcatJobs.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. require dirname(__FILE__, 2) . '/vendor/autoload.php';
  3. $secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
  4. $secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi
  5. $region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket
  6. $cosClient = new Qcloud\Cos\Client(
  7. array(
  8. 'region' => $region,
  9. 'schema' => 'https', //协议头部,默认为http
  10. 'credentials'=> array(
  11. 'secretId' => $secretId ,
  12. 'secretKey' => $secretKey)));
  13. try {
  14. // 提交拼接任务 https://cloud.tencent.com/document/product/436/54013
  15. // start --------------- 使用模版 ----------------- //
  16. $result = $cosClient->createMediaConcatJobs(array(
  17. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  18. 'Tag' => 'Concat',
  19. 'QueueId' => 'asdadadfafsdkjhfjghdfjg',
  20. 'CallBack' => 'https://example.com/callback',
  21. 'Input' => array(
  22. 'Object' => 'video01.mp4'
  23. ),
  24. 'Operation' => array(
  25. 'TemplateId' => 'asdfafiahfiushdfisdhfuis',
  26. 'Output' => array(
  27. 'Region' => $region,
  28. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  29. 'Object' => 'concat-video02.mp4',
  30. ),
  31. // 'UserData' => 'xxx', // 透传用户信息
  32. // 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
  33. ),
  34. ));
  35. // 请求成功
  36. print_r($result);
  37. // end --------------- 使用模版 ----------------- //
  38. // start --------------- 自定义参数 ----------------- //
  39. $result = $cosClient->createMediaConcatJobs(array(
  40. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  41. 'Tag' => 'Concat',
  42. 'QueueId' => 'asdadadfafsdkjhfjghdfjg',
  43. 'CallBack' => 'https://example.com/callback',
  44. 'Input' => array(
  45. 'Object' => 'video01.mp4'
  46. ),
  47. 'Operation' => array(
  48. // 'UserData' => 'xxx', // 透传用户信息
  49. // 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
  50. 'Output' => array(
  51. 'Region' => $region,
  52. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  53. 'Object' => 'concat-video03.mp4',
  54. ),
  55. 'ConcatTemplate' => array(
  56. 'ConcatFragments' => array(
  57. array(
  58. 'Url' => 'https://example.com/video01.mp4',
  59. 'Mode' => 'Start',
  60. // 'StartTime' => '0',
  61. // 'EndTime' => '7',
  62. ),
  63. array(
  64. 'Url' => 'https://example.com/video02.mp4',
  65. 'Mode' => 'Start',
  66. // 'StartTime' => '0',
  67. // 'EndTime' => '10',
  68. ),
  69. // ... repeated
  70. ),
  71. 'Index' => 1,
  72. 'Container' => array(
  73. 'Format' => 'mp4'
  74. ),
  75. 'Audio' => array(
  76. 'Codec' => 'mp3',
  77. 'Samplerate' => '',
  78. 'Bitrate' => '',
  79. 'Channels' => '',
  80. ),
  81. 'Video' => array(
  82. 'Codec' => 'H.264',
  83. 'Bitrate' => '1000',
  84. 'Width' => '1280',
  85. 'Height' => '',
  86. 'Fps' => '30',
  87. ),
  88. ),
  89. ),
  90. ));
  91. // 请求成功
  92. print_r($result);
  93. // end --------------- 自定义参数 ----------------- //
  94. } catch (\Exception $e) {
  95. // 请求失败
  96. echo($e);
  97. }