Пример #1
0
 public function testExecute2()
 {
     global $testAuth;
     $bucket = 'testres';
     $key = 'sintel_trailer.mp4';
     $fops = array('avthumb/m3u8/segtime/10/vcodec/libx264/s/320x240', 'vframe/jpg/offset/7/w/480/h/360');
     $pfop = new PersistentFop($testAuth, $bucket);
     list($id, $error) = $pfop->execute($key, $fops);
     $this->assertNull($error);
     list($status, $error) = PersistentFop::status($id);
     $this->assertNotNull($status);
     $this->assertNull($error);
 }
Пример #2
0
 public function testMkzip()
 {
     global $testAuth;
     $bucket = 'phpsdk';
     $key = 'php-logo.png';
     $pfop = new PersistentFop($testAuth, $bucket);
     $url1 = 'http://phpsdk.qiniudn.com/php-logo.png';
     $url2 = 'http://phpsdk.qiniudn.com/php-sdk.html';
     $zipKey = 'test.zip';
     $fops = 'mkzip/2/url/' . \Qiniu\base64_urlSafeEncode($url1);
     $fops .= '/url/' . \Qiniu\base64_urlSafeEncode($url2);
     $fops .= '|saveas/' . \Qiniu\base64_urlSafeEncode("{$bucket}:{$zipKey}");
     list($id, $error) = $pfop->execute($key, $fops);
     $this->assertNull($error);
     list($status, $error) = PersistentFop::status($id);
     $this->assertNotNull($status);
     $this->assertNull($error);
 }
Пример #3
0
 public function testExecute2()
 {
     global $testAuth;
     $pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
     $url_src1 = 'http://testres.qiniudn.com/gogopher.jpg';
     $url_en1 = \Qiniu\base64_urlSafeEncode($url_src1);
     $url_alias_en1 = \Qiniu\base64_urlSafeEncode('g.jpg');
     $url_en2 = $url_en1;
     $fop = "mkzip/2/url/{$url_en1}/alias/{$url_alias_en1}/url/{$url_en2}";
     $op = Operation::saveas($fop, 'phpsdk', 'mkziptest');
     $ops = array();
     array_push($ops, $op);
     list($id, $error) = $pfop->execute('sintel_trailer.mp4', $ops);
     $this->assertNull($error);
     list($status, $error) = PersistentFop::status($id);
     $this->assertNotNull($status);
     $this->assertNull($error);
 }
Пример #4
0
 /**
  * 对资源文件进行异步持久化处理
  * @param null $path 待处理的源文件
  * @param null $fops string|array  待处理的pfop操作,多个pfop操作以array的形式传入。
  * 多个pfop操作 ['avthumb/mp4/r/24/vcodec/libx264','avthumb/m3u8/noDomain/1/vb/500k/t/10']
  * @param null $pipeline 多媒体处理队列,详见 https://portal.qiniu.com/mps/pipeline
  * @return bool | int
  */
 public function persistentFop($path = null, $fops = null, $pipeline = null, $force = false)
 {
     $auth = $this->auth;
     $pipeline = is_null($pipeline) ? $this->pipeline : $pipeline;
     $pfop = new PersistentFop($auth, $this->bucket, $pipeline, $this->notify_url, $force);
     list($id, $error) = $pfop->execute($path, $fops);
     if ($error != null) {
         $this->writeLog($error);
         return false;
     } else {
         return $id;
     }
 }
Пример #5
0
//对已经上传到七牛的视频发起异步转码操作
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
//要转码的文件所在的空间和文件名。
$bucket = 'Bucket_Name';
$key = 'File_Name_On_Qiniu';
//转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
$pipeline = 'pipeline_name';
//转码完成后通知到你的业务服务器。
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
$pfop = new PersistentFop($auth, $bucket, $pipeline, $notifyUrl);
//需要添加水印的图片UrlSafeBase64,可以参考http://developer.qiniu.com/code/v6/api/dora-api/av/video-watermark.html
$base64URL = Qiniu\base64_urlSafeEncode('http://developer.qiniu.com/resource/logo-2.jpg');
//水印参数
$fops = "avthumb/mp4/s/640x360/vb/1.4m/image/" . $base64URL;
list($id, $err) = $pfop->execute($key, $fops);
echo "\n====> pfop avthumb result: \n";
if ($err != null) {
    var_dump($err);
} else {
    echo "PersistentFop Id: {$id}\n";
}
//查询转码的进度和状态
list($ret, $err) = $pfop->status($id);
echo "\n====> pfop avthumb status: \n";
if ($err != null) {
    var_dump($err);
} else {
    var_dump($ret);
}
Пример #6
0
 public function persistentFop($path = null, $fops = null)
 {
     $auth = $this->getAuth();
     $pfop = new PersistentFop($auth, $this->bucket);
     list($id, $error) = $pfop->execute($path, $fops);
     if ($error != null) {
         $this->logQiniuError($error);
         return false;
     } else {
         return $id;
     }
 }
Пример #7
0
 /**
  * 对资源文件进行异步持久化处理
  * @param string $path 待处理的源文件
  * @param string|array $fops 待处理的pfop操作,多个pfop操作以array的形式传入。
  * @return bool
  */
 public function persistentFop($path = null, $fops = null)
 {
     $auth = $this->getAuth();
     $pfop = new PersistentFop($auth, $this->bucket);
     list($id, $error) = $pfop->execute($path, $fops);
     return $this->returnDeal($id, $error);
 }
Пример #8
0
 /**
  * 持久化操作
  * @param  string $key
  * @param  string or array $fops 若有多个操作,传入数组
  * @param string $pipeline
  * @param string $notify_url
  * @param boolean $force 是否覆盖已有相同文件,未知会产生什么变化
  * @return stirng PersistentFopId
  */
 public function fop($key, $fops, $saveAs = '', $pipeline = null, $force = false)
 {
     if (!empty($saveAs)) {
         if (is_array($fops)) {
             $fops = implode(';', $fops);
         }
         $fops .= '|saveas/' . $this->urlEncode($this->bucket . ':' . $saveAs);
     }
     $fop = new PersistentFop($this['Auth'], $this->bucket, $pipeline, $this->config['notify_url'], $force);
     return $this->response($fop->execute($key, $fops));
 }
Пример #9
0
<?php

require_once "../bootstrap.php";
use Qiniu\Processing\PersistentFop;
$auth = new \Qiniu\Auth($QINIU_ACCESS_KEY, $QINIU_SECRET_KEY);
//原始待处理文件
$bucket = "if-pbl";
$key = "qiniu.jpg";
//结果保存
$saveBucket = "if-pri";
$saveKey = "qiniu_w100.jpg";
$pfop = new PersistentFop($auth, $bucket);
$fops = "imageView2/0/w/100|saveas/" . \Qiniu\base64_urlSafeEncode($saveBucket . ":" . $saveKey);
list($persistentId, $err) = $pfop->execute($key, $fops);
echo "\n====> pfop result: \n";
if ($err != null) {
    var_dump($err);
} else {
    echo "PersistentFop Id: {$persistentId}";
}