Пример #1
0
 public function testMkzip()
 {
     global $testAuth;
     $pfop = new PersistentFop($testAuth, 'testres', 'sdktest', true);
     $urls = array('http://testres.qiniudn.com/gogopher.jpg' => 'g.jpg', 'http://testres.qiniudn.com/gogopher.jpg');
     list($id, $error) = $pfop->mkzip('sintel_trailer.mp4', $urls, 'phpsdk', 'mkziptest2.zip');
     $this->assertNull($error);
     list($status, $error) = PersistentFop::status($id);
     $this->assertNotNull($status);
     $this->assertNull($error);
 }
Пример #2
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);
 }
Пример #3
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);
 }
Пример #4
0
 /**
  * 查询异步持久化处理的进度和状态
  * @param $id 触发持久化处理后返回的 Id
  * @return array
  */
 public function persistentStatus($id)
 {
     return PersistentFop::status($id);
 }
Пример #5
0
require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Processing\PersistentFop;
//对已经上传到七牛的视频发起异步转码操作
$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) {
Пример #6
0
function qiniu_get_pfop_status($id)
{
    return \Qiniu\Processing\PersistentFop::status($id);
}
Пример #7
0
<?php

require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Processing\PersistentFop;
// 去我们的portal 后台来获取AK, SK
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$key = '1.png';
// 异步任务的队列, 去后台新建: https://portal.qiniu.com/mps/pipeline
$pipeline = 'pipeline_name';
$pfop = new PersistentFop($auth, $bucket, $pipeline);
// 进行zip压缩的url
$url1 = 'http://rwxf.qiniudn.com/php-logo.png';
$url2 = 'http://rwxf.qiniudn.com/1.png';
//压缩后的key
$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, $err) = $pfop->execute($key, $fops);
echo "\n====> pfop mkzip result: \n";
if ($err != null) {
    var_dump($err);
} else {
    echo "PersistentFop Id: {$id}\n";
    $res = "http://api.qiniu.com/status/get/prefop?id={$id}";
    echo "Processing result: {$res}";
}
Пример #8
0
 /**
  * @param $id
  * @return mixed
  */
 public function fopStatus($id)
 {
     return $this->response(PersistentFop::status($id));
 }
<?php

require_once __DIR__ . '/../autoload.php';
use Qiniu\Processing\PersistentFop;
// 触发持久化处理后返回的 Id
$persistentId = 'z0.564d5f977823de48a85ece59';
// 通过persistentId查询该 触发持久化处理的状态
$status = PersistentFop::status($persistentId);
var_dump($status);
Пример #10
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}";
}