I am invoking aws lambda function from aws console and I am getting an error, Please help me my code is blowing
const ffmpeg = spawn('ffmpeg', ["-framerate", "0.5", "-i", myarray[0], "-i",
myarray[1], "-i", myarray[2], "-pix_fmt", "yuv420p", '-codec:v', 'libx264',
"/var/task/bin/video.mp4"]);
Error: spawn EACCES
at _errnoException (util.js:1022:11)
at ChildProcess.spawn (internal/child_process.js:323:11)
at exports.spawn (child_process.js:502:9)
at Timeout.setTimeout [as _onTimeout] (/var/task/handler.js:23:22)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
My Code
var AWS = require("aws-sdk");
var s3 = new AWS.S3();
const spawn = require('child_process').spawn;
var myarray = [];
//module.exports.hello
exports.handler = function (event, context, callback) {
return new Promise(function (resolve, reject) {
process.env.PATH = require("path").join(__dirname, "bin") + ":" + process.env['LAMBDA_TASK_ROOT'] +'; chmod 755 /tmp/bin/ffmpeg';
console.log(process.env.PATH);
GetImagesFromS3();
setTimeout(() => {
const ffmpeg = spawn('ffmpeg', ["-framerate", "0.5", "-i", myarray[0], "-i", myarray[1], "-i", myarray[2], "-pix_fmt", "yuv420p", '-codec:v', 'libx264', '/temp/video.mp4']);
ffmpeg.stderr.on('data', (data) => {
console.log(`${data}`);
});
ffmpeg.on('close', (code) => {
console.log('close', code)
});
ffmpeg.on('error', (code) => {
console.log('error', code)
});
}, 5000);
});
};
// get images from s3 bucket
function GetImagesFromS3() {
return new Promise(function (resolve, reject) {
var params = {
Bucket: 'hhotimages'
};
s3.listObjects(params, function (err, data) {
var bucketContents = data.Contents;
for (var i = 0; i < bucketContents.length; i++) {
var urlParams = {
Bucket: 'hhotimages',
Key: bucketContents[i].Key
};
s3.getSignedUrl('getObject', urlParams, function (err, url) {
console.log('the url of the image is', url);
myarray.push(url);
});
}
});
});
}