尝试使用 ffmpeg 时 AWS Lambda 权限被拒绝 [英] AWS Lambda permission denied when trying to use ffmpeg

查看:32
本文介绍了尝试使用 ffmpeg 时 AWS Lambda 权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个响应 S3 put 事件的处理程序来转换任何上传到 mp4 的 avi 文件.我在 Java 中,在 Eclipse 中使用 AWS 工具包插件进行操作.对于视频转换,我将 ffmpeg 与 ffmpeg-cli-wrapper 一起使用,并且我提供了源代码树中 ffmpeg 的静态 (linux) 二进制文件.

I want to write a handler that responds to S3 put events to convert any avi files that are uploaded to mp4. I doing it in Java, in Eclipse, with the AWS toolkit plugin. For video conversion, I am using ffmpeg with ffmpeg-cli-wrapper, and I have provided a static (linux) binary of ffmpeg in the source tree.

我发现当我上传函数时,二进制文件被放入/var/task,但是当我尝试使用我编写的测试函数时,我得到权限被拒绝"" 错误.

I have found that when I upload the function, the binary gets put in /var/task, but when I try to use the test function I've written, I get a "permission denied" error.

import net.bramp.ffmpeg.FFmpeg;

public class LambdaFunctionHandler implements RequestHandler<S3Event, String> {

    private static final String FFMPEG = "/var/task/ffmpeg";

    public String handleRequest(S3Event event, Context context) {

        try {
            FFmpeg ff = new FFmpeg(FFMPEG);
            System.out.println(ff.version());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "foo";
    }
}

和堆栈跟踪的第一行:java.io.IOException:Cannot run program "/var/task/ffmpeg": error=13, Permission denied.

And the first line of the stacktrace: java.io.IOException: Cannot run program "/var/task/ffmpeg": error=13, Permission denied.

我如何执行这个二进制文件?我已经按照其他人的建议做了,并且在上传之前 chmod 755 二进制文件,但它没有任何区别.

How do I execute this binary? I have done as others have suggested and chmod 755 the binary before uploading, but it hasn't made a difference.

推荐答案

AWS Lambda 在 Amazon Linux 上运行.这是一个已知问题.尝试构建(启用静态)并检查它是否适用于 Amazon Linux 并上传该二进制文件.您无权对 /var/task/ 中的文件进行 chmod.或者试试这个有效的解决方案:

AWS Lambda runs on Amazon Linux. It is a known issue. Try building (with static enabled) and check if it works on Amazon Linux and upload that binary. You do not have the privileges to chmod the files in /var/task/. Or try this solution that works:

  • 移动 ffmpeg/tmp
  • chmod 755/tmp/ffmpeg
  • 调用/tmp/ffmpeg

有关详细信息,请参阅此讨论.

See this discussion for more info.

这篇关于尝试使用 ffmpeg 时 AWS Lambda 权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆