Git Product home page Git Product logo

av-pretreatment-php-sdk's Introduction

又拍云视频预处理 PHP-SDK

不推荐再使用,功能已经集成到 https://github.com/upyun/php-sdk

build

目录

安装说明

要求

php 5.3+

通过composer安装

1.安装composer

curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

2.在你的项目根目录下创建composer.json,并添加如下内容

{
    "repositories": [
        {   
            "type": "vcs",
            "url": "https://github.com/upyun/av-pretreatment-php-sdk.git"
        }   
    ],  
    "require":{
        "upyun/sugar-php-sdk":"dev-master"
    }   
}

3.运行 composer install

4.在项目中添加如下代码

//注意修改项目根目录
include '/your/project/root/path/vendor/autoload.php'

github下载压缩包安装

通过github直接下载最新稳定版,在项目中添加以下代码

include "Sugar/AvPretreatment.php";
include "Sugar/CallbackValidation.php";
include "Sugar/Tasks.php";

示例

AvPretreatment 类提交视频预处理请求

use Sugar\AvPretreatment;
use Sugar\CallbackValidation;

$sugar = new AvPretreatment('operator_name', 'operator_password');//操作员的帐号密码
$data = array(
    'bucket_name' => 'your_bucket_name',        //空间名
    'source' => '/video/20130514_190031.mp4',   //空间视频地址
    'notify_url' => 'http://callback/',         //回调通知地址
    'tasks' => array(                           //针对一个视频,可以有多种处理任务
        array(
            'type' => 'hls',
            'hls_time' => 6,
            'bitrate' => '500',
            'rotate' =>  'auto',
            'thumb_format' => 'mp4',
        ),
        array(
            'type' => 'thumbnail',
            'thumb_single' => false,
            'thumb_amount' => 100,
            'thumb_format' => 'png'
        ),
    )
);
try {
    //返回对应的任务ids
    $ids = $sugar->request($data);
} catch(\Exception $e) {
    echo "request failed:", $e->getMessage();
}

Tasks 类 批量处理同一个空间的多个视频

当需要对同一个空间多个视频做相同的任务处理时,可以使用Tasks

use Sugar\AvPretreatment;
use Sugar\Tasks;
use Sugar\CallbackValidation;

//需要将 operator_name opeartor_pwd your_bucket_name替换成自己的操作员帐号密码和空间名
$avPretreatment = new AvPretreatment('operator_name', 'operator_pwd');
$tasks = new Tasks('your_bucket_name', 'http://callback/', $avPretreatment);
$data =array(
    array(
        'type' => 'hls',
        'hls_time' => 6,
        'bitrate' => '500',
        'rotate' =>  'auto',
        'thumb_format' => 'mp4',
    ),
    array(
        'type' => 'thumbnail',
        'thumb_single' => false,
        'thumb_amount' => 100,
        'thumb_format' => 'png'
    ),
);
$tasks->addTasks($data);
//待处理的多个视频
$videoFiles = array('/video/path1', '/video/path2', '/video/path3')
foreach($videoFiles as $url) {
    $tasks->setSource($url);
    $ids[$url] = $tasks->run();
}

回调地址验证示例:

在回调代码中,添加如下验证

use Sugar\AvPretreatment;
use Sugar\CallbackValidation;
//需要将 operator_name opeartor_pwd 替换成自己的操作员帐号密码
$av = new AvPretreatment('operator_name', 'operator_pwd');
$validation = new CallbackValidation($av);
if($validation->verifySign()) {
    echo '验证成功';
} else {
    echo '验证失败';
}

贡献代码

  1. Fork
  2. 为新特性创建一个新的分支
  3. 发送一个 pull request 到 develop 分支

社区

许可证

UPYUN 视频处理PHP-SDK基于 MIT 开源协议

http://www.opensource.org/licenses/MIT

av-pretreatment-php-sdk's People

Contributors

sabakugaara avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.