Git Product home page Git Product logo

aws-autotranscode's Introduction

AWS Lambda to encode incoming media files automagically

This is an AWS Lambda Javascript function that works as an automated HLS streaming media encoder triggered by new files in S3, by creating jobs in AWS Elastic Transcoder. It's compatible with testing locally with node.js thanks to the Lambda boilerplate by SC5. Inspiration from the Sitebase example on github.

Quick Start (run in the cloud)

  • Paste src/index.js content to a AWS Lambda code editor
  • Fill in the correct bucket names, metadata and pipeline ID
  • Set the script as handler for AWS S3 ObjectCreated (All) events, with a file extension filter for your media file type
  • Make sure the Lambda role has permissions to read and write to the buckets you chose.

Manifest file

The code assumes the following structure in the source bucket:

[bucket-root]/[mediaID]/manifest.json
[bucket-root]/[mediaID]/[media-file-name].[ext]

Take a look at the sample directory for a sample. The manifest file is mainly used in our setup to copy human-selected thumbnails and metadata to the right place along the publishing process, but the script could be adapted to use just the media file as input. manifest.json has the following structure:

{
    "mediaID":"0daa547b24de47cab0b1fdd20fd5dad0",
    "date":1441257874000,
    "thumbnails":["0daa547b24de47cab0b1fdd20fd5dad0_large.jpg"],
    "media":"0daa547b24de47cab0b1fdd20fd5dad0_hybe_teaser_45s-v2.mp4"
}

NOTE the manifest file must be present in the directory when the media file triggers the lambda, otherwise the script will fail. This has not been a problem in the HYBE.com setup at least - the media file transfer takes the longest time over the metadata.

Outputs

By default, the script generates HLS playlists for adaptive streaming to compatible clients - modern browsers and devices - using the AWS Elastic Transcoder presets. These can be easily changed, added, removed etc.

Installation for local testing

Prerequisites

Clone the project and trigger installation of the project dependencies by

> git clone https://github.com/hybe/aws-autotranscode.git [module name]
> cd [module name]
> npm install

Set up your AWS credentials e.g. to ~/.aws/credentials (see http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html). e.g.

[default]
aws_access_key_id = [YOUR_ACCESS_KEY_ID]
aws_secret_access_key = [YOUR_SECRET_ACCESS_KEY]

Set up your lambda environment by copying example_lambdaenv.json to lambdaenv.json and setting the parameter values. You will need an AWS IAM role for use with your Lambda function.

Development

Set up your module information into package.json prior to deployment

Project layout

src/    The source of the Lambda function (index.js)
tests/  The tests for the Lambda function. Tests to run must start with test_
gulpfile.js     The gulpfile used for deployment
package.json    The package file for the module. Defines the function name, version and dependencies

Testing locally

Run gulp tests.

> gulp test

Tests reside in the tests/directory. Uses lambda-wrapper module to wrap the code.

Deploying to AWS

The module is deployed to Lambda using

> gulp deploy

This will create a new lamda function to the region defined in lambdaenv.json with the name [module_name]_[version] (cleaned up from illegal characters)

Release History

  • 2016/01/05 - v0.1.0 - Initial version of the transcoder lambda

License

Copyright (c) 2016 HYBE Media, licensed for users and contributors under MIT license. https://github.com/sc5/grunt-bobrsass-boilerplate/blob/master/LICENSE-MIT

Bitdeli Badge

aws-autotranscode's People

Contributors

mpuittinen avatar pippuri avatar stoicism2323 avatar

Stargazers

 avatar

Watchers

 avatar

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.