123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- include_once '../vendor/aliyun/aliyun-php-sdk-core/Config.php';
- use Mts\Request\V20140618 as Mts;
- class Mps extends Api
- {
-
-
-
-
-
- protected $noNeedLogin = ['mpsvideo'];
-
- protected $noNeedRight = [''];
-
- public function mpsvideo()
- {
- $access_key_id = 'LTAI5tRun9ZQVSgeg9mbjzjh';
- $access_key_secret = 'nIkOAGe5Xttrjn7B5s0flk4z8zCdw8';
- $mps_region_id = 'cn-hangzhou';
- $pipeline_id = '0c4f9b648be54da09e29d8819f60a0df';
- $watermark_template_id = '0c09ed4ef64e424b89a3449bcc0de522';
- $template_id = '4c43c0ff9436425dbb6eaf2ce74e0ff0';
- $oss_location = 'oss-cn-hangzhou';
- $oss_bucket = 'eyefate';
- $oss_input_object = 'uploads/2022330/ZWIFbwAxNmdF.mp4';
- $oss_output_object = 'output/2022330/ZWIFbwAxNmdF.mp4';
- $image_watermark_object = 'logo.png';
- $clientProfile = \DefaultProfile::getProfile(
- $mps_region_id,
- $access_key_id,
- $access_key_secret
- );
- $client = new \DefaultAcsClient($clientProfile);
- $request = new Mts\SubmitJobsRequest();
- $request->setAcceptFormat('JSON');
- $input = array('Location' => $oss_location,
- 'Bucket' => $oss_bucket,
- 'Object' => urlencode($oss_input_object));
- $request->setInput(json_encode($input));
- $output = array('OutputObject' => urlencode($oss_output_object));
- $output['TemplateId'] = $template_id;
- $image_watermark_input = array(
- 'Location' => $oss_location,
- 'Bucket' => $oss_bucket,
- 'Object' => urlencode($image_watermark_object)
- );
- $image_watermark = array(
- 'WaterMarkTemplateId' => $watermark_template_id,
- 'Type' => 'Image',
- 'InputFile' => $image_watermark_input,
- 'Dx' => 100,
- 'Dy'=> 50
- );
-
-
- $watermarks = array($image_watermark);
- $output['WaterMarks'] = $watermarks;
- $outputs = array($output);
- $request->setOUtputs(json_encode($outputs));
- $request->setOutputBucket($oss_bucket);
- $request->setOutputLocation($oss_location);
- $request->setPipelineId($pipeline_id);
- try {
- $response = $client->getAcsResponse($request);
- print 'RequestId is:' . $response->{'RequestId'} . "\n";;
- if ($response->{'JobResultList'}->{'JobResult'}[0]->{'Success'}) {
- print 'JobId is:' .
- $response->{'JobResultList'}->{'JobResult'}[0]->{'Job'}->{'JobId'} . "\n";
- } else {
- print 'SubmitJobs Failed code:' .
- $response->{'JobResultList'}->{'JobResult'}[0]->{'Code'} .
- ' message:' .
- $response->{'JobResultList'}->{'JobResult'}[0]->{'Message'} . "\n";
- }
- } catch(ServerException $e) {
- print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
- } catch(ClientException $e) {
- print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
- }
- }
- }
|