PHP code example of minz / laravel-qiniu-dora
1. Go to this page and download the library: Download minz/laravel-qiniu-dora library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
minz / laravel-qiniu-dora example snippets
'providers' => [
......
Minz\Laravel\Qiniu\OSS\QiniuDoraServiceProvider::class,
],
'aliases' => [
......
'Dora' => Minz\Laravel\Qiniu\Dora\QiniuDoraFacade::class,
],
/**
* 对资源文件进行异步持久化处理
*
* @param string $fileKey 存储于bucket中的资源key
* @param $fops string|array 待处理的pfop操作,多个pfop操作以array的形式传入。
* eg. avthumb/mp3/ab/192k, vframe/jpg/offset/7/w/480/h/360
* @param string|null $pipeline 多媒体队列名称,默认使用配置文件
* @param string|null $notifyUrl 回调服务器地址
* @param bool $force 如果key相同是否强制覆盖object 默认为false
* @return array (返回持久化处理的persistentId, 返回的错误)
*/
public function execute(string $fileKey, $fops, string $pipeline = null, string $notifyUrl = null, bool $force = false)
#打水印图片公共读地址
$imgUrl = "http:yourPictireUrl";
#七牛kodo资源名称
$fileKey = "demo.wmv";
#打水印后视频另存为地址 必须为 bucket:saveKey base64Encode
$videoSaveKey = config('qiniuDora.bucket') . ":" . "yourVideoSaveKey";
#截取视频某个帧另存为图片 必须为 bucket:saveKey base64Encode
$pictureSaveKey = config('qiniuDora.bucket') . ":" . "yourPictureSaveKey";
//格式请参考七牛dora api 文档
$fops = [
"avthumb/mp4/r/15/vb/256k/vcodec/libx264/ab/64k/acodec/libfaac/wmImage/" . base64_encode($imgUrl) . "|saveas/" . base64_encode($videoSaveKey),
"vframe/jpg/offset/5|saveas/" . base64_encode($pictureSaveKey)
];
list($id, $err) = Dora::execute($fileKey, $fops);
shell
php artisan vendor:publish --provider="Minz\Laravel\Qiniu\Dora\QiniuDoraServiceProvider"