Skip to content

Instantly share code, notes, and snippets.

@mitchellporter
Forked from russau/demo.js
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellporter/d4aeb71c416dff062c8b to your computer and use it in GitHub Desktop.
Save mitchellporter/d4aeb71c416dff062c8b to your computer and use it in GitHub Desktop.
console.log('Loading event');
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
console.log('Received event:');
console.log(JSON.stringify(event, null, ' '));
// Get the object from the event and show its content type
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
var output = Math.random().toString(36).substring(7) + ".webm";
console.log("Video processing for: " + key);
var elastictranscoder = new AWS.ElasticTranscoder({ region : "us-east-1" })
var params = {
Input: { /* required */
AspectRatio: "auto",
Container: "auto",
FrameRate: "auto",
Interlaced: "auto",
Key: key,
Resolution: "auto"
},
PipelineId: "1423975421228-rxhwv2", /* required */
OutputKeyPrefix: "s3demo/",
Outputs: [
{
Key: output,
PresetId: "1423984395335-y4axq4",
Rotate: "auto",
Watermarks: [
{
InputKey: "webm.png",
PresetWatermarkId: "BottomRight"
},
]
},
],
Playlists: [],
UserMetadata: {}
};
elastictranscoder.createJob(params, function(err, data) {
if (err) {
console.log('error processing ' + key );
context.done('error','error processing '+err);
}
else {
console.log(data);
context.done(null,'');
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment