|
@@ -75,10 +75,74 @@ class Qiniu
|
|
$config = Dever::db('upload/upload')->one($key);
|
|
$config = Dever::db('upload/upload')->one($key);
|
|
|
|
|
|
if ($config) {
|
|
if ($config) {
|
|
|
|
+
|
|
|
|
+ if ($config['yun'] > 0 && $config['vod_convert'] == 2) {
|
|
|
|
+ $yun = Dever::db('upload/yun')->one($config['yun']);
|
|
|
|
+ if ($yun) {
|
|
|
|
+ $this->convert($key, $file, $config, $yun);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
$this->initFile($key, $file, $source);
|
|
$this->initFile($key, $file, $source);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private function convert($key, $file, $config, $yun)
|
|
|
|
+ {
|
|
|
|
+ $accessKey = $yun['appkey'];
|
|
|
|
+ $secretKey = $yun['appsecret'];
|
|
|
|
+ $host = $yun['host'];
|
|
|
|
+ $auth = new \Qiniu\Auth($accessKey, $secretKey);
|
|
|
|
+ $bucket = $config['bucket'];
|
|
|
|
+
|
|
|
|
+ # 转码
|
|
|
|
+ //转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
|
|
|
|
+ $pipeline = $config['pipeline'];
|
|
|
|
+ if ($pipeline) {
|
|
|
|
+ $array = explode(',', $pipeline);
|
|
|
|
+ $index = array_rand($array);
|
|
|
|
+ if (isset($array[$index])) {
|
|
|
|
+ $pipeline = $array[$index];
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $pipeline = 'convert';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ext = 'mp4';
|
|
|
|
+
|
|
|
|
+ if (strstr($file, '.mp3') || strstr($file, '.wma') || strstr($file, '.wav')) {
|
|
|
|
+ $ext = 'mp3';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $force = false;
|
|
|
|
+ //转码完成后通知到你的业务服务器。
|
|
|
|
+ $notifyUrl = 'http://375dec79.ngrok.com/notify.php';
|
|
|
|
+ $notifyUrl = false;
|
|
|
|
+ $config = new \Qiniu\Config();
|
|
|
|
+ //$config->useHTTPS=true;
|
|
|
|
+ $pfop = new \Qiniu\Processing\PersistentFop($auth, $config);
|
|
|
|
+ //要进行转码的转码操作。 http://developer.qiniu.com/docs/v6/api/reference/fop/av/avthumb.html
|
|
|
|
+ //$fops = "avthumb/m3u8/s/640x360/vb/1.4m|saveas/" . \Qiniu\base64_urlSafeEncode($bucket . ":qiniu_640x360.mp4");
|
|
|
|
+ $fops = "avthumb/mp4/vb/1.4m|saveas/" . \Qiniu\base64_urlSafeEncode($bucket . ':' . $file . '_c.' . $ext);
|
|
|
|
+ list($id, $err) = $pfop->execute($bucket, $file, $fops, $pipeline, $notifyUrl, $force);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ echo "\n====> pfop avthumb result: \n";
|
|
|
|
+ if ($err != null) {
|
|
|
|
+ var_dump($err);
|
|
|
|
+ } else {
|
|
|
|
+ echo "PersistentFop Id: $id\n";
|
|
|
|
+ }
|
|
|
|
+ die;
|
|
|
|
+ //查询转码的进度和状态
|
|
|
|
+ list($ret, $err) = $pfop->status($id);
|
|
|
|
+ echo "\n====> pfop avthumb status: \n";
|
|
|
|
+ if ($err != null) {
|
|
|
|
+ var_dump($err);
|
|
|
|
+ } else {
|
|
|
|
+ var_dump($ret);
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+
|
|
public function token()
|
|
public function token()
|
|
{
|
|
{
|
|
$result = Dever::input('result', 2);
|
|
$result = Dever::input('result', 2);
|