You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
1 year ago
|
<?php
|
||
|
require_once __DIR__ . '/../autoload.php';
|
||
|
|
||
|
use Qiniu\Auth;
|
||
|
use Qiniu\Processing\PersistentFop;
|
||
|
|
||
|
//对已经上传到七牛的视频发起异步转码操作
|
||
|
$accessKey = getenv('QINIU_ACCESS_KEY');
|
||
|
$secretKey = getenv('QINIU_SECRET_KEY');
|
||
|
$bucket = getenv('QINIU_TEST_BUCKET');
|
||
|
$auth = new Auth($accessKey, $secretKey);
|
||
|
|
||
|
//要转码的文件所在的空间和文件名。
|
||
|
$key = 'qiniu.mp4';
|
||
|
|
||
|
//转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
|
||
|
$pipeline = 'sdktest';
|
||
|
|
||
|
//转码完成后通知到你的业务服务器。
|
||
|
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
|
||
|
$force = false;
|
||
|
|
||
|
$config = new \Qiniu\Config();
|
||
|
$config->useHTTPS = true;
|
||
|
$pfop = new PersistentFop($auth, $config);
|
||
|
|
||
|
//要进行视频截图操作
|
||
|
$fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90|saveas/" .
|
||
|
\Qiniu\base64_urlSafeEncode($bucket . ":qiniu_480x360.jpg");
|
||
|
|
||
|
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notifyUrl, $force);
|
||
|
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);
|
||
|
}
|