


The first thing we do here is copying the FFmpeg folder to the tmp folder, then we give the execute permission to the FFmpeg file using the chmod node package. In here I am trying to merge two files into one. Muxing an audio file and a video file into one video file // This could be any operation on FFmpeg, you just have to give the parameters correctly. Give execute permissions to the ffmpeg */ // ncp will copy the whole directory to /tmp/ffmpegĬlobber: false, // Do not overwrite if already exists (Lambda sometimes re-uses the container) So I had to copy the ffmpeg to the temp folder and give it execute permissions to make it work In Lambda all locations except /tmp are read only. We can't run the ffmpeg from the current folder because it is read only. const exec = require( "child_process").execFileĮxports.mux = async (audioFile, videoFile, muxedFile) => Let’s jump right into a code which executes FFmpeg. Run npm install chmod ncp - save to install the packages. You will need to have chmod and ncp installed to run this code. The package folder will look like something like this after extracting FFmpeg You can download file which is the one matches the Lambda machine and extract it inside your Lambda function package. after much searching, I found this website by this cool dude, Where he has listed a set of static builds of FFmpeg for different environments. To run FFmpeg you have to have a build that is compatible with the Lambda environment. You will have to give necessary permissions to execute FFmpeg from /tmp folder.Copy the FFmpeg to the /tmp folder when you are going to execute it because you can’t execute anything from anywhere other than /tmp folder in Lambda.Need to find an executable Which works on the Lambda server.In that case, you will face some problems, What if you want to run FFmpeg from a Lambda function? When you have a requirement to do something on video/ audio files, the tool of choice would be FFmpeg which is free and open source.
