Lambda 未连接到 ffmpeg [英] Lambda not connecting to ffmpeg
问题描述
我遇到了 Lambda 函数的问题,该函数试图在 AWS 上将 ffmpeg 用作第三方.该函数本身使用 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
下载 x86_64 版本.因为它使用了我的 lambda 环境
解压文件并复制 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屋!