47 lines
1.2 KiB
PHP
Raw Normal View History

2023-05-10 13:39:12 +08:00
<?php
require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Processing\PersistentFop;
2024-02-28 16:51:38 +08:00
//对已经上传到七牛的视频发起异步转码操作
2023-05-10 13:39:12 +08:00
$accessKey = getenv('QINIU_ACCESS_KEY');
$secretKey = getenv('QINIU_SECRET_KEY');
2024-02-28 16:51:38 +08:00
$bucket = getenv('QINIU_TEST_BUCKET');
2023-05-10 13:39:12 +08:00
$auth = new Auth($accessKey, $secretKey);
2024-02-28 16:51:38 +08:00
//要转码的文件所在的空间和文件名。
2023-05-10 13:39:12 +08:00
$key = 'qiniu.mp4';
2024-02-28 16:51:38 +08:00
//转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
2023-05-10 13:39:12 +08:00
$pipeline = 'sdktest';
2024-02-28 16:51:38 +08:00
//转码完成后通知到你的业务服务器。
2023-05-10 13:39:12 +08:00
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
$force = false;
2024-02-28 16:51:38 +08:00
$config = new \Qiniu\Config();
2023-05-10 13:39:12 +08:00
$config->useHTTPS = true;
$pfop = new PersistentFop($auth, $config);
2024-02-28 16:51:38 +08:00
//要进行视频截图操作
2023-05-10 13:39:12 +08:00
$fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90|saveas/" .
2024-02-28 16:51:38 +08:00
\Qiniu\base64_urlSafeEncode($bucket . ":qiniu_480x360.jpg");
2023-05-10 13:39:12 +08:00
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";
}
2024-02-28 16:51:38 +08:00
//查询转码的进度和状态
2023-05-10 13:39:12 +08:00
list($ret, $err) = $pfop->status($id);
echo "\n====> pfop avthumb status: \n";
if ($err != null) {
var_dump($err);
} else {
var_dump($ret);
}