我正在从aws控制台调用aws lambda函数,但出现错误,请帮我,我的代码正在吹动
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"]);
错误:生成EACCES
_errnoException(util.js:1022:11)
在ChildProcess.spawn(internal / child_process.js:323:11)
在exports.spawn(child_process.js:502:9)
在Timeout.setTimeout [作为_onTimeout](/var/task/handler.js:23:22)
于ontimeout(timers.js:482:11)
在tryOnTimeout(timers.js:317:5)
在Timer.listOnTimeout(timers.js:277:5)
我的代码
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);
});
}
});
});
}
答案 0 :(得分:0)
您似乎已经在通过lambda函数运送ffmpeg了,否则您将获得ENOENT
。
但是,您打包的ffmpeg
需要设置可执行位(打包之前的chmod +x ffmpeg
)。没有此功能,您将无权执行ffmpeg,这可能就是为什么您获得EACCES
的原因。
如果您的ffmpeg是针对非lambda环境编译的,则您可能也会得到此提示。