Skip to content

Commit 1b72ee5

Browse files
authored
Merge pull request #187 from clouddxy/add_some_demos
add_some_demos [ci skip]
2 parents bc9a61e + 5acf6f7 commit 1b72ee5

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

examples/pfop_ vframe.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
require_once __DIR__ . '/../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Processing\PersistentFop;
6+
7+
//对已经上传到七牛的视频发起异步转码操作
8+
9+
$accessKey = 'Access_Key';
10+
$secretKey = 'Secret_Key';
11+
$auth = new Auth($accessKey, $secretKey);
12+
13+
//要转码的文件所在的空间和文件名。
14+
$bucket = 'Bucket_Name';
15+
$key = 'File_Name_On_Qiniu';
16+
17+
//转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
18+
$pipeline = 'pipeline_name';
19+
20+
//转码完成后通知到你的业务服务器。
21+
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
22+
$pfop = new PersistentFop($auth, $bucket, $pipeline, $notifyUrl);
23+
24+
//要进行视频截图操作
25+
$fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90";
26+
27+
list($id, $err) = $pfop->execute($key, $fops);
28+
echo "\n====> pfop avthumb result: \n";
29+
if ($err != null) {
30+
var_dump($err);
31+
} else {
32+
echo "PersistentFop Id: $id\n";
33+
}
34+
35+
//查询转码的进度和状态
36+
list($ret, $err) = $pfop->status($id);
37+
echo "\n====> pfop avthumb status: \n";
38+
if ($err != null) {
39+
var_dump($err);
40+
} else {
41+
var_dump($ret);
42+
}

examples/pfop_ watermark.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
require_once __DIR__ . '/../autoload.php';
3+
4+
use Qiniu\Auth;
5+
use Qiniu\Processing\PersistentFop;
6+
7+
//对已经上传到七牛的视频发起异步转码操作
8+
9+
$accessKey = 'Access_Key';
10+
$secretKey = 'Secret_Key';
11+
$auth = new Auth($accessKey, $secretKey);
12+
13+
//要转码的文件所在的空间和文件名。
14+
$bucket = 'Bucket_Name';
15+
$key = 'File_Name_On_Qiniu';
16+
17+
//转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
18+
$pipeline = 'pipeline_name';
19+
20+
//转码完成后通知到你的业务服务器。
21+
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
22+
$pfop = new PersistentFop($auth, $bucket, $pipeline, $notifyUrl);
23+
24+
//需要添加水印的图片UrlSafeBase64,可以参考http://developer.qiniu.com/code/v6/api/dora-api/av/video-watermark.html
25+
$base64URL = Qiniu\base64_urlSafeEncode('http://developer.qiniu.com/resource/logo-2.jpg');
26+
27+
//水印参数
28+
$fops = "avthumb/mp4/s/640x360/vb/1.4m/image/".$base64URL;
29+
30+
list($id, $err) = $pfop->execute($key, $fops);
31+
echo "\n====> pfop avthumb result: \n";
32+
if ($err != null) {
33+
var_dump($err);
34+
} else {
35+
echo "PersistentFop Id: $id\n";
36+
}
37+
38+
//查询转码的进度和状态
39+
list($ret, $err) = $pfop->status($id);
40+
echo "\n====> pfop avthumb status: \n";
41+
if ($err != null) {
42+
var_dump($err);
43+
} else {
44+
var_dump($ret);
45+
}

0 commit comments

Comments
 (0)