Skip to content

Instantly share code, notes, and snippets.

@matthewberryman
Created May 18, 2018 00:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewberryman/f87ecaeba87684e950416eeeae7d6c78 to your computer and use it in GitHub Desktop.
Save matthewberryman/f87ecaeba87684e950416eeeae7d6c78 to your computer and use it in GitHub Desktop.
batch transcode using AWS Elastic Transcoder
const AWS= require('aws-sdk');
AWS.config.update({region: 'ap-southeast-2'}); // set your region here
const elastictranscoder = new AWS.ElasticTranscoder();
const s3 = new AWS.S3();
var params = {
Bucket: 'my-bucket',
}
s3.listObjects(params, function (err, data) {
if (err) throw err;
for (let i = 0; i < data.Contents.length ; i++) {
let inputKey = data.Contents[i].Key;
if (inputKey.endsWith('.MOV')) {
let output720Key = inputKey.replace('.MOV','_720p.mp4');
let output1080Key = inputKey.replace('.MOV','_1080p.mp4');
elastictranscoder.createJob({
PipelineId: '1526599050314-tqkw92', // specifies output/input buckets in S3
Input: {
Key: inputKey,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Output: {
Key: output1080Key,
ThumbnailPattern: '',
PresetId: '1351620000001-000001', // specifies the output video format as generic 1080p
Rotate: 'auto'
}
}, function(err, data) {
if (err) throw err;
console.log(data);
});
elastictranscoder.createJob({
PipelineId: 'PipelineId', // specifies output/input buckets in S3
Input: {
Key: inputKey,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Output: {
Key: output720Key,
ThumbnailPattern: '',
PresetId: '1351620000001-000010', // specifies the output video format as generic 1080p
Rotate: 'auto'
}
}, function(err, data) {
if (err) throw err;
console.log(data);
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment