issetbv/hatchery-api-client

此包的最新版本(5.0.4)没有可用的许可证信息。

PHP 的 Hatchery API 客户端

5.0.4 2018-03-21 16:31 UTC

README

这是 http://my.videotranscoder.io/ API 的客户端。使用它来简化 PHP 中 API 的使用。

示例

API 需要消费者密钥和私钥,可以在 info@my.videotranscoder.io 上申请。

    <?php

    include '../src/Hatchery/Autoloader.php';
    
    $authentication = new Hatchery\Authentication\KeyPairAuthentication('consumer_key', 'private_key');
    $client  = new Hatchery\Client('api_url', $authentication);
    
    //create a new job, this class will contain all inputs and outputs
    $job = new Hatchery\Builder\Job();
    
    //create a new input, this class has to contain a valid URL and can be used to create outputs
    $input = new Hatchery\Builder\Input(new Hatchery\Builder\Url\Url('ftp://my_ftp_in_location.com/folder/input_file.mp4'));
    
    //create a new output, which links to a specific input and requires an output URL
    //this class also opens up some methods to manipulate your output
    $output = new Hatchery\Builder\Output($input, new Hatchery\Builder\Url\Url('ftp://my_ftp_out_location.com/folder/output_file.webm'));
    
    //use the name of own of your presets, or use on of the default video-transcoder presets
    $output->setPreset('My_own_webm_preset');
    
    //example of a number option, use the value objects to initiate
    $output->setOutputLength(new Hatchery\Builder\ValueObjects\Number(60));
    
    //example of creating stills
    $stills = new Hatchery\Builder\Stills(new Hatchery\Builder\Url\Url('ftp://my_ftp_out_location.com/folder/my_stills_folder/'));
    $stills->setFilename('my_stills_frame_{{number}}');
    $stills->setAmount(new Hatchery\Builder\ValueObjects\Number(5));

    //add stills task to a specific output
    $output->addStills($stills);
    
    //add in- and outputs to job
    $job->add($input);
    $job->add($output);

    //submit job
    $response = $client->submitJob($job);
    
    //retrieve polling location (containing job id)
    $location = $response->getLocation();