Lambda未连接到ffmpeg [英] Lambda not connecting to ffmpeg
问题描述
我遇到一个Lambda函数问题,该函数试图将ffmpeg用作AWS上的第三方.该函数本身使用ffmpeg.js库,该库在调用函数时会在其函数中生成ffmpeg命令.我通过SSH在实例上安装了ffmpeg,但仍然给我同样的错误
I have an issue with a Lambda function that tries to use ffmpeg as a third party on AWS. The function itself uses ffmpeg.js library which generates ffmpeg commands in it's functions, when they are called. I installed ffmpeg on my instance via SSH, and it's still giving me the same error
命令失败:ffmpeg -i".... ffmpeg:找不到命令
Command failed: ffmpeg -i ".... ffmpeg: command not found
对此有何建议?非常感谢
Any advice on this? Many thanks
推荐答案
您需要在项目目录中包含ffmpeg的静态构建
You need to include static build of ffmpeg inside your project directory
解压缩文件,然后复制名为ffmpeg的二进制构建文件,并将其粘贴到您的项目目录中.
Unzip the file and copy ffmpeg named file which is binary build and paste it in your project directory.
之后,在代码顶部粘贴以下代码段:
After that on the top of your code paste the following snippet:
process.env.PATH = process.env.PATH + ':/tmp/'
process.env['FFMPEG_PATH'] = '/tmp/ffmpeg';
const BIN_PATH = process.env['LAMBDA_TASK_ROOT']
rocess.env['PATH'] = process.env['PATH'] + ':' + BIN_PATH;
现在,在exports.handler中,将以下代码行粘贴到函数调用的开头.看起来像这样
Now inside your exports.handler, paste the following line of code in the beginning of function call. It will look like this
exports.handler = function(event, context, callback) {
require('child_process').exec(
'cp /var/task/ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg;',
function (error, stdout, stderr) {
if (error) {
console.log('Erro occured',error);
} else {
var ffmpeg = require('ffmpeg');
// Your task to be performed
}
}
)
}
我希望这会有所帮助.别忘了竖起大拇指:) 上面的解决方案是针对Node.js语言的
I hope this helps. Don't forget to leave a thumbs up :) Above solution is for Node.js language
这篇关于Lambda未连接到ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!