尝试使用ffmpeg时拒绝AWS Lambda权限 [英] AWS Lambda permission denied when trying to use ffmpeg
问题描述
我想编写一个响应S3 put事件的处理程序,以将上载到mp4的所有avi文件转换为.我使用AWS工具包插件在Java中,Eclipse中进行了此操作.对于视频转换,我将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上运行并上传该二进制文件.您没有权限chmod
/var/task/
中的文件.或尝试以下可行的解决方案:
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
- Move
ffmpeg
to/tmp
chmod 755 /tmp/ffmpeg
- Call
/tmp/ffmpeg
有关更多信息,请参见此讨论.
See this discussion for more info.
这篇关于尝试使用ffmpeg时拒绝AWS Lambda权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!