0

我按照本教程制作 ffmpeg lambda 层https://www.serverless.com/blog/publish-aws-lambda-layers-serverless-framework

我使用 spawnsync 在我的目录中运行 ls 并且 opt 目录为空,因此 ffmpeg 没有触发。

关于我可能做错了什么的任何指示?

我使用 node.js12.x 作为无服务器框架的运行时。

4

1 回答 1

0

if you add

spawnSync( 'ls', ["/opt"], { stdio: "inherit" });

in your lambda code, you may see that ffmpeg execute file is directly under /opt. it depends on how you zipped the ffmpeg folder. With the command above you could see the /opt folder structure to know with which path to call ffmpeg exe.

spawnSync(
  '/opt/ffmpeg',
  [
    '-i',
    `/tmp/${inputFileName}`,
    "-f",
    "gif",
    `/tmp/${outputFileName}`
  ],
  { stdio: "inherit" }
);

It works for me.

于 2020-09-25T03:17:20.680 回答