我有一个AWS Lambda函数,我试图将视频放入S3存储桶并对其进行转码。我需要加密转码文件。该函数适用于直接转码,但当我尝试添加加密部分时,它会无声地失败。日志中没有错误,但也没有输出文件。任何帮助,将不胜感激。以下是相关代码。
'use strict';
var AWS = require('aws-sdk');
var s3 = new AWS.S3({
apiVersion: '2012–09–25'
});
var eltr = new AWS.ElasticTranscoder({
apiVersion: '2012–09–25',
region: 'us-east-1'
});
exports.handler = function(event, context) {
console.log('Executing Elastic Transcoder Orchestrator');
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
var pipelineId = 'PIPLINEID';
var split = key.split('.');
var nameandfolder = split[0];
var split2 = nameandfolder.split('/');
var name = split2[1];
console.log(bucket);
if (bucket !== 'project') {
context.fail('Incorrect Video Input Bucket');
return;
}
var params = {
PipelineId: pipelineId,
OutputKeyPrefix: 'Transcode_Output/',
Input: {
Key: key,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Outputs: [{
Key: name + '.mp4',
PresetId: 'PRESETID',
Encryption: {
Mode: 's3-aws-kms',
},
}]
};
console.log('Starting Job');
eltr.createJob(params, function(err, data){
if (err){
console.log(err);
} else {
console.log(data);
}
context.succeed('Job well done');
});
};