hoangstark/shufu-encoder-sdk

v1.1.1 2019-07-07 09:37 UTC

This package is auto-updated.

Last update: 2024-09-17 01:09:56 UTC


README

Latest Version on Packagist Build Status Total Downloads

Use this SDK to login via username & password, then get the access token.

Installation

You can install the package via composer:

composer require hoangstark/shufu-encoder-sdk

Usage

Login

<?php

namespace App\Http\Controllers;

use Hoangstark\ShufuEncoderSdk\ShufuEncoderSdk;

class LoginController extends Controller
{
    protected function login()
    {
        $shufuEncoder = new ShufuEncoderSdk;
        $shufuEncoder->login('http://localhost/api', 'shufu', 'secret');
        return $shufuEncoder->getAccessToken();
    }
}

Get tasks

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$tasks = $shufuEncoder->getTasks();

Get encoding tasks

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$tasks = $shufuEncoder->getEncodingTasks();

Get single task

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$task = $shufuEncoder->getTask(1);

Get single task encoding progress

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$percentage = $shufuEncoder->getTaskProgress(1);

Create task

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$task = $shufuEncoder->createTask(array(
    "webhook_success" => "https://enpii3jcfpr19.x.pipedream.net",
    "webhook_error" => "https://en4vdjmi70ib.x.pipedream.net/",
    "s3_filename" => "test",
    "s3_path" => "encoded/a/c",
    "s3_region" => "eu-central-1",
    "s3_bucket" => "shufu-encoder",
    "s3_key" => "...",
    "s3_secret" => "...",
    "encode_formats" => array(
        array(
            "width" => 1280,
            "height" => 0,
            "video_kilobitrate" => "1500",
            "audio_kilobitrate" => "128",
            "video_codec" => "libx264",
            "audio_codec" => "aac",
            "profile" => "main",
            "preset" => "veryfast"
        ),
        array(
            "width" => 720,
            "height" => 0,
            "video_kilobitrate" => "750",
            "audio_kilobitrate" => "128",
            "video_codec" => "libx264",
            "audio_codec" => "aac",
            "profile" => "main",
            "preset" => "veryfast",
        )
    ),
));

echo $task->message // Task created

Update task

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$task = $shufuEncoder->updateTask(1, array(
    "webhook_success" => "https://enpii3jcfpr19.x.pipedream.net",
    "webhook_error" => "https://en4vdjmi70ib.x.pipedream.net/",
    "s3_filename" => "test",
    "s3_path" => "encoded/a/c",
    "s3_region" => "eu-central-1",
    "s3_bucket" => "shufu-encoder",
    "s3_key" => "...",
    "s3_secret" => "...",
    "encode_formats" => array(
        array(
            "width" => 1280,
            "height" => 0,
            "video_kilobitrate" => "1500",
            "audio_kilobitrate" => "128",
            "video_codec" => "libx264",
            "audio_codec" => "aac",
            "profile" => "main",
            "preset" => "veryfast"
        ),
        array(
            "width" => 720,
            "height" => 0,
            "video_kilobitrate" => "750",
            "audio_kilobitrate" => "128",
            "video_codec" => "libx264",
            "audio_codec" => "aac",
            "profile" => "main",
            "preset" => "veryfast",
        )
    ),
));

echo $task->message // Task updated

Dispatch task to queue

$shufuEncoder = new ShufuEncoderSdk;
$shufuEncoder->login('http://localhost:8080/api', 'shufu', 'secret');

$queue = $shufuEncoder->queueTask(1);

echo $queue->message // Task does not have file | Task already encoded | Task queue dispatched

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.