The goal of this repository is to compile a functioning ffmpeg binary with the following properties:
- Static
- Runs on Amazon Lambda node22.x / Amazon Linux 2023
- Runs on x86 / amd64
- Modern version of ffmpeg (>=7)
- Can process common types of audio like mp3, aac, and mp4
- Supports https/tls
- Space-efficient since Lambda functions are limited to ~262MB
- Current binary sizes are 27.8MB (ffmeg) and 27.7MB (ffprobe).
If you just want a compiled version of ffmpeg/ffprobe, either to use on an AWS Lambda Layer or to copy to your function, you can find it in releases.
You'll need to do some setup before running the build script:
- Install Docker Desktop
If the pre-built version doesn't work for you, you can build it yourself:
- Run
./build.shto compileffmpegandffprobein a docker image - Run
./extract.shto extract them and zip them up - (Optional) Upload the .zip to an AWS Lambda Layer
AWS Lambda defaults to x86 so this compiles for x86 by default. To change this:
- Update
build.shandextract.sh- Replace
--platform=linux/amd64with--platform=linux/arm64
- Replace
- Update hardcoded compilation targets in
Dockerfile- Replace
RUN ./Configure no-shared linux-x86_64 --prefix=$PREFIX --libdir=libwithRUN ./Configure no-shared linux-aarch64 --prefix=$PREFIX --libdir=lib
- Replace
Update the Dockerfile and run build.sh until it works.
If you want to compile for other flavors of Linux, check out these docker images: https://github.com/jrottenberg/ffmpeg/tree/main/docker-images
If you don't need https/tls support:
- You can use John Van Sickle's builds. They work on Amazon Lambda 2023, but attempting to use https will trigger a segfault:
ffmpeg was killed with signal SIGSEGV. - You can also use the popular ffmpeg-lambda-layer which has the same issue, but it's still on FFmpeg 4.
If you don't mind having a large binary, you can use https://github.com/BtbN/FFmpeg-Builds/releases. You can get a functioning ~240MB Lambda layer by doing the following:
- Download the shared build
ffmpeg-master-latest-linux64-gpl-shared - Delete
ffplay - Zip with symlinks disabled:
zip -r9 --symlinks ffmpeg-master-latest-linux64-gpl-shared.zip . - Upload it to S3
- Create a layer and point it to that S3 link