createMediaVideoProcessJobs.php 6.4 KB

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