This project builds FFmpeg static libraries (.a files) for linux/amd64 architecture from source. It uses Docker to provide a consistent cross-platform build environment, allowing you to build Linux binaries from macOS.
- Docker (with support for linux/amd64 platform by default)
- Bash shell
- Internet connection (to clone FFmpeg repository)
Simply run the build script:
./build.shThis will:
- Build a Docker image with all necessary build dependencies
- Clone the FFmpeg repository
- Compile FFmpeg as static libraries
- Output the
.afiles to theoutput/lib/directory
The build process will generate the following static libraries:
libavcodec.a- Audio/video codec librarylibavdevice.a- Device handling librarylibavfilter.a- Audio/video filtering librarylibavformat.a- Audio/video container format librarylibavutil.a- Utility librarylibpostproc.a- Video post-processing librarylibswresample.a- Audio resampling librarylibswscale.a- Video scaling and color conversion library
All libraries will be located in output/lib/ after a successful build.
Header files will be in output/include/.
You can specify a different FFmpeg version by setting the FFMPEG_VERSION environment variable:
# Build a specific release version
FFMPEG_VERSION=n6.1 ./build.shDefault version: n5.1.4 (FFmpeg 5.1.4)
The libraries are built with the following configuration:
- Static libraries only (no shared libraries)
- Position Independent Code (PIC) enabled
- No programs (ffmpeg, ffprobe, etc.)
- No documentation
- Debug symbols disabled
- Optimized for library usage
To perform a clean build, remove the output directory:
rm -rf output/
./build.sh- Target Platform: linux/amd64 (default)
- Build Platform: Can be run from macOS (including M1/M2/M3/M4) or Linux
- Docker Platform: The build uses
--platform ${PLATFORM}to ensure consistent output regardless of host architecture
If you encounter platform-related errors, ensure Docker Desktop has support for linux/amd64 enabled. On Apple Silicon Macs, this requires Rosetta 2:
softwareupdate --install-rosettaIf the build fails:
- Check Docker is running:
docker ps - Remove cached containers:
docker system prune - Try a clean build by removing
output/directory
The first build will take longer as it needs to:
- Download the Docker base image
- Install build dependencies
- Clone the FFmpeg repository
- Compile all libraries
Subsequent builds will be faster if you keep the output/ directory.
This build script is provided as-is. FFmpeg itself is licensed under LGPL 2.1+ or GPL 2+ depending on configuration. See the FFmpeg License for details.