简体   繁体   English

AWS Lambda:如何给 ffmpeg 大文件?

[英]AWS Lambda: how to give ffmpeg large files?

Scenario:设想:

Using AWS Lambda (Node.js), I want to process large files from S3 ( > 1GB).使用 AWS Lambda (Node.js),我想处理来自 S3 (> 1GB) 的大文件。 The /tmp fs limit of 512MB means that I can't copy the S3 input there. 512MB 的 /tmp fs 限制意味着我不能在那里复制 S3 输入。 I can certainly increase the Lambda memory space, in order to read in the files.我当然可以增加 Lambda 内存空间,以便读入文件。

  • Do I pass the memory buffer to ffmpeg?我是否将内存缓冲区传递给 ffmpeg? (node.js, how?) (node.js,怎么样?)
  • Or....should I just make an EFS mount point and use that as the transcoding scratchpad?或者....我应该只创建一个 EFS 挂载点并将其用作转码暂存器吗?

You can just use the HTTP(s) protocol as input for ffmpeg.您可以只使用 HTTP(s) 协议作为 ffmpeg 的输入。

Lambda has max 10GB memory limit, and data transfer speed from S3 is around 300MB per second the last time I test. Lambda 有最大 10GB 的内存限制,我上次测试时 S3 的数据传输速度约为每秒 300MB。 So if you have only 1GB max video and are not doing memory intensive transformation, this approach should work fine因此,如果您只有 1GB 最大视频并且没有进行内存密集型转换,这种方法应该可以正常工作

ffmpeg -i "https://public-qk.s3.ap-southeast-1.amazonaws.com/sample.mp4" -ss 00:00:10 -vframes 1 -f image2 "image%03d.jpg"

ffmpeg works on files, so maybe an alternative would be to setup a unix pipe and then read that pipe with ffmpeg, constantly feeding it with the s3 stream. ffmpeg 处理文件,所以也许另一种方法是设置一个 unix 管道,然后用 ffmpeg 读取该管道,不断地用 s3 流提供它。

But maybe you'd wanna consider running this as an ECS task instead, you wouldn't have a time constraint, and not the same storage constraint either.但也许你想考虑将其作为 ECS 任务运行,你不会有时间限制,也不会有相同的存储限制。 Cold start of it using Fargate would be 1-2 minutes though, which maybe isn't acceptable?不过,使用 Fargate 冷启动需要 1-2 分钟,这可能是不可接受的?

Lambda now supports up to 10Gb storage: Lambda 现在支持高达 10Gb 的存储:

https://aws.amazon.com/blogs/aws/aws-lambda-now-supports-up-to-10-gb-ephemeral-storage/ https://aws.amazon.com/blogs/aws/aws-lambda-now-supports-up-to-10-gb-ephemeral-storage/

Lambda 不支持高达 10Gb 的存储

Update with cli: $ aws lambda update-function-configuration --function-name PDFGenerator --ephemeral-storage '{"Size": 10240}'使用 cli 更新: $ aws lambda update-function-configuration --function-name PDFGenerator --ephemeral-storage '{"Size": 10240}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM