Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
704 views
in Technique[技术] by (71.8m points)

linux - AWS Lambda permission denied when trying to use ffmpeg

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.

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";
    }
}

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  • Move ffmpeg to /tmp
  • chmod 755 /tmp/ffmpeg
  • Call /tmp/ffmpeg

See this discussion for more info.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...