PHP code example of hoangstark / shufu-encoder-sdk

1. Go to this page and download the library: Download hoangstark/shufu-encoder-sdk 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/ */

    

hoangstark / shufu-encoder-sdk example snippets


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

$tasks = $shufuEncoder->getTasks();

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

$tasks = $shufuEncoder->getEncodingTasks();

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

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

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

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

$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

$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

$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
 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();
    }
}