createMediaVideoProcessJobs.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. 'scheme' => 'https', //协议头部,默认为http
  10. 'credentials'=> array(
  11. 'secretId' => $secretId,
  12. 'secretKey' => $secretKey)));
  13. try {
  14. // 提交视频增强任务 https://cloud.tencent.com/document/product/436/60750
  15. // start --------------- 使用模版 ----------------- //
  16. $result = $cosClient->createMediaVideoProcessJobs(array(
  17. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  18. 'Tag' => 'VideoProcess',
  19. 'Input' => array(
  20. 'Object' => 'video01.mp4'
  21. ),
  22. 'Operation' => array(
  23. 'TemplateId' => 't13466f1ea41a14c0xxxxxxxxxxxxx', // 视频增强模板 ID
  24. 'TranscodeTemplateId' => 't0b6a845f5e42847bd81xxxxxxxxxxxxx', // 转码模板 ID
  25. 'WatermarkTemplateId' => 't185e2e24551b24259a0xxxxxxxxxxxxx', // 水印模板 ID
  26. 'Output' => array(
  27. 'Region' => $region,
  28. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  29. 'Object' => 'VideoProcess.flv',
  30. ),
  31. // 'UserData' => 'xxx', // 透传用户信息
  32. // 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
  33. ),
  34. 'CallBack' => '',
  35. ));
  36. // 请求成功
  37. print_r($result);
  38. // end --------------- 使用模版 ----------------- //
  39. // start --------------- 自定义参数 ----------------- //
  40. $result = $cosClient->createMediaVideoProcessJobs(array(
  41. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  42. 'Tag' => 'VideoProcess',
  43. 'Input' => array(
  44. 'Object' => 'video01.mp4'
  45. ),
  46. 'Operation' => array(
  47. 'VideoProcess' => array(
  48. 'ColorEnhance' => array(
  49. 'Enable' => '',
  50. 'Contrast' => '',
  51. 'Correction' => '',
  52. 'Saturation' => '',
  53. ),
  54. 'MsSharpen' => array(
  55. 'Enable' => '',
  56. 'SharpenLevel' => '',
  57. ),
  58. ),
  59. 'Transcode' => array(
  60. 'Tag' => '',
  61. 'Name' => '',
  62. 'Container' => array(
  63. 'Format' => '',
  64. ),
  65. 'Video' => array(
  66. 'Codec' => '',
  67. 'Width' => '',
  68. 'Height' => '',
  69. 'Fps' => '',
  70. 'Remove' => '',
  71. 'Profile' => '',
  72. 'Bitrate' => '',
  73. 'Crf' => '',
  74. 'Gop' => '',
  75. 'Preset' => '',
  76. 'Bufsize' => '',
  77. 'Maxrate' => '',
  78. 'HlsTsTime' => '',
  79. 'Pixfmt' => '',
  80. 'LongShortMode' => '',
  81. ),
  82. 'TimeInterval' => array(
  83. 'Start' => '',
  84. 'Duration' => '',
  85. ),
  86. 'Audio' => array(
  87. 'Codec' => '',
  88. 'Samplerate' => '',
  89. 'Bitrate' => '',
  90. 'Channels' => '',
  91. 'Remove' => '',
  92. 'KeepTwoTracks' => '',
  93. 'SwitchTrack' => '',
  94. 'SampleFormat' => '',
  95. ),
  96. 'TransConfig' => array(
  97. 'AdjDarMethod' => '',
  98. 'IsCheckReso' => '',
  99. 'ResoAdjMethod' => '',
  100. 'IsCheckVideoBitrate' => '',
  101. 'VideoBitrateAdjMethod' => '',
  102. 'IsCheckAudioBitrate' => '',
  103. 'AudioBitrateAdjMethod' => '',
  104. 'DeleteMetadata' => '',
  105. 'IsHdr2Sdr' => '',
  106. 'HlsEncrypt' => array(
  107. 'IsHlsEncrypt' => '',
  108. 'UriKey' => '',
  109. ),
  110. ),
  111. ),
  112. 'Watermark' => array(
  113. 'Type' => '',
  114. 'Pos' => '',
  115. 'LocMode' => '',
  116. 'Dx' => '',
  117. 'Dy' => '',
  118. 'StartTime' => '',
  119. 'EndTime' => '',
  120. 'Image' => array(
  121. 'Url' => '',
  122. 'Mode' => '',
  123. 'Width' => '',
  124. 'Height' => '',
  125. 'Transparency' => '',
  126. 'Background' => '',
  127. ),
  128. 'Text' => array(
  129. 'FontSize' => '',
  130. 'FontType' => '',
  131. 'FontColor' => '',
  132. 'Transparency' => '',
  133. 'Text' => '',
  134. ),
  135. ),
  136. 'Output' => array(
  137. 'Region' => $region,
  138. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  139. 'Object' => 'VideoProcess.flv',
  140. ),
  141. // 'UserData' => 'xxx', // 透传用户信息
  142. // 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
  143. ),
  144. 'CallBack' => '',
  145. ));
  146. // 请求成功
  147. print_r($result);
  148. // end --------------- 自定义参数 ----------------- //
  149. } catch (\Exception $e) {
  150. // 请求失败
  151. echo($e);
  152. }