2016-04-02 39 views
0

我正在AWS Lambda上运行视频处理脚本。'在AWS上找不到模块fluent-ffmpeg'Lambda

虽然它似乎完全本地工作(使用lambda-local测试),我有一个奇怪的问题,当它运行在LAMBDA:

{ 
    "errorMessage": "Cannot find module 'fluent-ffmpeg'", 
    "errorType": "Error", 
    "stackTrace": [ 
    "Function.Module._resolveFilename (module.js:338:15)", 
    "Function.Module._load (module.js:280:25)", 
    "Module.require (module.js:364:17)", 
    "require (module.js:380:17)", 
    "Object.<anonymous> (/var/task/processing.js:2:14)", 
    "Module._compile (module.js:456:26)", 
    "Object.Module._extensions..js (module.js:474:10)", 
    "Module.load (module.js:356:32)", 
    "Function.Module._load (module.js:312:12)", 
    "Module.require (module.js:364:17)" 
    ] 
} 

我上传包含以下文件的ZIP:

~$ find . -maxdepth 2 
. 
./bin 
./bin/ffmpeg 
./config.js 
./event-samples 
./event-samples/custom.js 
./event-samples/dynamodb-update.js 
./event-samples/kinesis.js 
./event-samples/s3-put.js 
./frames 
./Gulpfile.js 
./index.js 
./node_modules 
./node_modules/async 
./node_modules/aws-sdk 
./node_modules/fluent-ffmpeg 
./node_modules/gulp 
./node_modules/gulp-awslambda 
./node_modules/gulp-zip 
./package.json 
./processing.js 
./utils.js 

(马车需要位于processing.js

如果我打开ZIP,node_modules/fluent-ffmpeg/*确实存在。

我想包括使用模块:

  • require("./node_modules/fluent-ffmpeg/index")
  • require(__dirname + "./node_modules/fluent-ffmpeg/index")
  • require(process.env.LAMBDA_TASK_ROOT + "/node_modules/fluent-ffmpeg/index")

但所有这些问题迎刃而解。我也尝试在我的机器上重新安装节点和npm,rm -rf node_modulesnpm install(以防万一)。

由于Lambda运行节点0.10.36,我也尝试在我的机器上使用此版本来执行npm install,但是这也不会改变任何内容。

帮助赞赏。

谢谢!

+1

也许试试[AWS分叉](https://github.com/binoculars/aws-lambda-ffmpeg)? – Andy

+0

除非我误解了,否则此库用于调整大小并生成视频缩略图,对吧?在这种情况下,不适用于我需要做的事(提取视频的每一帧) – christophetd

+0

对不起,我以为它是同一个库。 – Andy

回答

1

已解决。我的开发机器运行的是Windows 7,这显然是造成这个问题的原因......但是,对原因感兴趣。

无论如何,在linux安装上运行npm install并将代码上传到Lambda的确有窍门。