createMediaAnimationJobs.php 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/54001
  15. // start --------------- 使用模版 ----------------- //
  16. $result = $cosClient->createMediaAnimationJobs(array(
  17. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  18. 'Tag' => 'Animation',
  19. 'QueueId' => 'p81e648af2aee49688xxxxxxxxxxxxxxxx',
  20. 'Input' => array(
  21. 'Object' => 'video01.mp4'
  22. ),
  23. 'Operation' => array(
  24. 'TemplateId' => 't1de276cbdab16xxxxxxxxxxxxxxxxxxxxx',
  25. 'Output' => array(
  26. 'Region' => $region,
  27. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  28. 'Object' => 'Animation.gif',
  29. ),
  30. // 'UserData' => 'xxx', // 透传用户信息
  31. // 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
  32. ),
  33. 'CallBack' => '',
  34. ));
  35. // 请求成功
  36. print_r($result);
  37. // end --------------- 使用模版 ----------------- //
  38. // start --------------- 自定义参数 ----------------- //
  39. $result = $cosClient->createMediaAnimationJobs(array(
  40. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  41. 'Tag' => 'Animation',
  42. 'QueueId' => 'p81e648af2aee49688xxxxxxxxxxxxxxxx',
  43. 'Input' => array(
  44. 'Object' => 'video01.mp4'
  45. ),
  46. 'Operation' => array(
  47. 'Animation' => array(
  48. 'Container' => array(
  49. 'Format' => '',
  50. ),
  51. 'Video' => array(
  52. 'Codec' => '',
  53. 'Width' => '',
  54. 'Height' => '',
  55. 'Fps' => '',
  56. 'AnimateOnlyKeepKeyFrame' => '',
  57. 'AnimateTimeIntervalOfFrame' => '',
  58. 'AnimateFramesPerSecond' => '',
  59. 'Quality' => '',
  60. ),
  61. 'TimeInterval' => array(
  62. 'Start' => '',
  63. 'Duration' => '',
  64. ),
  65. ),
  66. 'Output' => array(
  67. 'Region' => $region,
  68. 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket
  69. 'Object' => 'Animation.gif',
  70. ),
  71. // 'UserData' => 'xxx', // 透传用户信息
  72. // 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0
  73. ),
  74. 'CallBack' => '',
  75. ));
  76. // 请求成功
  77. print_r($result);
  78. // end --------------- 自定义参数 ----------------- //
  79. } catch (\Exception $e) {
  80. // 请求失败
  81. echo($e);
  82. }