Amazon Elastic Transcoder API – Laravel 5

Here is simple example to create job  to transcode mp3 file to HLS-Audio for Amazon Elastic Transcoder .

include the package in composer https://github.com/aws/aws-sdk-php-laravel


<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use AWS;

class DexelUploadAudio extends Controller
{

public function __construct()
{

/* ... */
}

public function createjob()
{
$result = $ElasticTranscoder = AWS::createClient('ElasticTranscoder');
//pipeline id 1489836190416-r56a8n
//dd($ElasticTranscoder->listPipelines());
$ElasticTranscoder->createJob([
//pipeline id refer it in transcoder page eg : https://ap-southeast-2.console.aws.amazon.com/elastictranscoder/home?region=ap-southeast-2#pipelines:
'PipelineId'=>'XXXXXXXXX',
'Input' => [
//input file, which should exist in the bucket which is specified on pipeline
'Key' => 'sample.mp3',
'FrameRate' => 'auto',
'Resolution' => 'auto',
'AspectRatio' => 'auto',
'Interlaced' => 'auto',
'Container' => 'auto',
],
'Outputs'=>[
[
//output prefix file name
'Key' =>'string',
//System preset: HLS Audio - 64k

//Preset id refer it in transcoder page eg : https://ap-southeast-2.console.aws.amazon.com/elastictranscoder/home?region=ap-southeast-2#presets:

'PresetId'=>'XXXXXXXXXXX',
//seconds to split to file
'SegmentDuration'=>'10'
]
],
//output folder name
'OutputKeyPrefix'=>'string/'
]);
dd($result);
}
public function jobStatus($jobId)
 {
 $ElasticTranscoder = AWS::createClient('ElasticTranscoder');
 $result = $ElasticTranscoder->readJob(['Id' => $jobId]);
 dd($result);
 }
}

Advertisements