|
| 1 | +<?php |
| 2 | + |
| 3 | +require dirname(__FILE__) . '/../vendor/autoload.php'; |
| 4 | + |
| 5 | +$secretId = "SECRETID"; //"云 API 密钥 SecretId"; |
| 6 | +$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey"; |
| 7 | +$region = "ap-beijing"; //设置一个默认的存储桶地域 |
| 8 | +$cosClient = new Qcloud\Cos\Client( |
| 9 | + array( |
| 10 | + 'region' => $region, |
| 11 | + 'schema' => 'https', //协议头部,默认为http |
| 12 | + 'credentials'=> array( |
| 13 | + 'secretId' => $secretId , |
| 14 | + 'secretKey' => $secretKey))); |
| 15 | +try { |
| 16 | + // start --------------- 使用模版 ----------------- // |
| 17 | + $result = $cosClient->createMediaConcatJobs(array( |
| 18 | + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID |
| 19 | + 'Tag' => 'Concat', |
| 20 | + 'QueueId' => 'asdadadfafsdkjhfjghdfjg', |
| 21 | + 'CallBack' => 'https://example.com/callback', |
| 22 | + 'Input' => array( |
| 23 | + 'Object' => 'video01.mp4' |
| 24 | + ), |
| 25 | + 'Operation' => array( |
| 26 | + 'TemplateId' => 'asdfafiahfiushdfisdhfuis', |
| 27 | + 'Output' => array( |
| 28 | + 'Region' => $region, |
| 29 | + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID |
| 30 | + 'Object' => 'concat-video02.mp4', |
| 31 | + ), |
| 32 | + ), |
| 33 | + )); |
| 34 | + // 请求成功 |
| 35 | + print_r($result); |
| 36 | + // end --------------- 使用模版 ----------------- // |
| 37 | + |
| 38 | + // start --------------- 自定义参数 ----------------- // |
| 39 | + $result = $cosClient->createMediaConcatJobs(array( |
| 40 | + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID |
| 41 | + 'Tag' => 'Concat', |
| 42 | + 'QueueId' => 'asdadadfafsdkjhfjghdfjg', |
| 43 | + 'CallBack' => 'https://example.com/callback', |
| 44 | + 'Input' => array( |
| 45 | + 'Object' => 'video01.mp4' |
| 46 | + ), |
| 47 | + 'Operation' => array( |
| 48 | + 'Output' => array( |
| 49 | + 'Region' => $region, |
| 50 | + 'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID |
| 51 | + 'Object' => 'concat-video03.mp4', |
| 52 | + ), |
| 53 | + 'ConcatTemplate' => array( |
| 54 | + 'ConcatFragments' => array( |
| 55 | + array( |
| 56 | + 'Url' => 'https://example.com/video01.mp4', |
| 57 | + 'Mode' => 'Start', |
| 58 | +// 'StartTime' => '0', |
| 59 | +// 'EndTime' => '7', |
| 60 | + ), |
| 61 | + array( |
| 62 | + 'Url' => 'https://example.com/video02.mp4', |
| 63 | + 'Mode' => 'Start', |
| 64 | +// 'StartTime' => '0', |
| 65 | +// 'EndTime' => '10', |
| 66 | + ), |
| 67 | + // ... repeated |
| 68 | + ), |
| 69 | + 'Index' => 1, |
| 70 | + 'Container' => array( |
| 71 | + 'Format' => 'mp4' |
| 72 | + ), |
| 73 | + 'Audio' => array( |
| 74 | + 'Codec' => 'mp3', |
| 75 | + 'Samplerate' => '', |
| 76 | + 'Bitrate' => '', |
| 77 | + 'Channels' => '', |
| 78 | + ), |
| 79 | + 'Video' => array( |
| 80 | + 'Codec' => 'H.264', |
| 81 | + 'Bitrate' => '1000', |
| 82 | + 'Width' => '1280', |
| 83 | + 'Height' => '', |
| 84 | + 'Fps' => '30', |
| 85 | + ), |
| 86 | + ), |
| 87 | + ), |
| 88 | + )); |
| 89 | + // 请求成功 |
| 90 | + print_r($result); |
| 91 | + // end --------------- 自定义参数 ----------------- // |
| 92 | +} catch (\Exception $e) { |
| 93 | + // 请求失败 |
| 94 | + echo($e); |
| 95 | +} |
| 96 | + |
0 commit comments