Coder Social home page Coder Social logo

elastcoder's Introduction

Elastcoder

Build Status Latest Stable Version Author

AWS Elastic Transcoder integration for Laravel. This is a simple wrapper if you don't want to go too deep with the AWS SDK for PHP 3.x!.

Installation

Require this package with composer:

composer require dumpk/elastcoder

Add this variables to your .env with your Amazon credentials

AWS_ACCESS_KEY_ID={AMAZONACCESSKEY}
AWS_SECRET_ACCESS_KEY={SECRETAMAZONSOMETHINGLONG}
AWS_REGION={YOURREGION}

Usage

Add the ElastcoderAWS class to your class header

use Dumpk\Elastcoder\ElastcoderAWS;

Now you just need to instance your class

$elastcoder = new ElastcoderAWS();

You'll need to have your video uploaded to S3 before using this library, so that means that you already have the key for the file you want to encode. The configuration has to look like:

$config = [
    'PresetId' => '432423-dsda',
    'width'  => 1920,
    'height' => 1080,
    'aspect' => '16:9',
	'ext'	 => 'mp4',
	'PipelineId' => '343244232-n2fuqq4',
    'Watermarks' => [[
            'PresetWatermarkId' => 'BottomRight',
            'InputKey'          => '1080.png',
    ]],
]

There's an example file you can throw in on your config folder in dumpk/elastcoder/example/elastcoder.php remember to change the values for the pipeline and presetId you want and you have configured on your AWS account.

So now you can call the transcoding function:

$job = $elastcoder->transcodeVideo($asset->key, $destinationKey, $config, $thumbPattern);

This will return a job with an array, where you can find the "Id" of the Job, you'll need to check the job for completeness to know if your video is ready. Buy you already know that, so for your convienience you can use:

$job = $elastcoder->getJob($job["Id"]);

And check if $job['Status'] == 'complete'

Also you can change the ACL of your file, because you might want to give access to everyone to see your amazing video, so:

$elastcoder->setPublicObject($key, $bucket);

If you want to be more specific about that and have different types of permissions, you can use:

$elastcoder->setObjectACL($key, $bucket, $acl);

$acl can be a string with this values => private|public-read|public-read-write|authenticated-read|bucket-owner-read|bucket-owner-full-control

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.