If you like the script, please “” ★ this project! The
FFmpeg build script
provides an easy way to create a static FFmpeg on macOS and Linux with optional non-free codecs and GPL (-enable-gpl-and-non-free, see https://ffmpeg.org/legal.html) included. Youtube: How to create and install FFmpeg on macOS
Disclaimer and Data Privacy Notice
This script will download different packages with different licenses from various sources, which can track their usage. These sources are out of control by the developers of this script. In addition, this script can create a non-free and non-redistributable binary. By downloading and using this script, you are fully aware of this.
Use this script at your own risk. I keep this script in my spare time. Please do not file bug reports for systems other than Debian and macOS, because I do not have the resources or time to maintain different systems.
Installation
Quick
install and run (macOS, Linux) Open the command
line and run (curl must be installed):
This command downloads the build script and automatically starts the build process
.
Common installation (macOS, Linux
)
Supported codecs
x264: H.264 video codec (
- MPEG-4 AVC) x265
- H.265
- libsvtav1: SVT-AV1 encoder and decoder
- aom: AV1 video codec (Experimental and very slow!)
- librav1e: oxide-based
- libdav1d: The fastest AV1 decoder developed by the VideoLAN and FFmpeg communities and sponsored by AOMedia (only available if meson and ninja are installed)
- fdk_aac: Fraunhofer FDK AAC xvidcore
- MPEG-4 video encoding standard
- webm: VP8/VP9 video codec for WebM
- video file format mp3: MPEG-1 or MPEG-2 Audio Layer III
- Free Open Container Format
- vorbis
- Theora
- Audio Encoding Format
- SRT: Safe and reliable transport
- WebP: Lossless and lossy image format
:
video codec (HEVC)
AV1 encoder (only available if the payload is installed)
codec:
VP8/VP9/
ogg:
: Lossy Audio Compression Format
: Free lossy video compression format Opus: Lossy
HardwareAccel
- nv-codec: NVIDIA GPU-accelerated video codecs. These encoders/decoders will only be available if a CUDA installation was encountered while compiling the binary. Follow these installation instructions. Compatible codecs in nvcodec: H264 h264_cuvid H265 decoders
-
- hevc_cuvid
- Motion JPEG mjpeg_cuvid
- mpeg2_cuvid MPEG4
- part 2 video mepg4_cuvid
- VC-1 vc1_cuvid
- VP8 vp8_cuvid VP9
- vp9_cuvid
MPEG1 video mpeg1_cuvid MPEG2 video
H264
nvenc_h264 H265 encoders
-
- nvenc_hevc
-
- vaapi: Video acceleration API. These encoders/decoders will only be available if a libva driver installation was encountered while compiling the binary. Follow these installation instructions. Supported codecs in vaapi:
- H264
- h264_vaapi H265
- hevc_vaapi
- Motion JPEG mjpeg_vaapi
- MPEG2 mpeg2_vaapi VP8 vp8_vaapi VP9 video
- vp9_vaapi
encoders
- H264
- AMF: Advanced Media Framework from AMD. These encoders will only be available if amdgpu drivers are detected in use on the system with lspci -v.
-
- H264
encoders h264_amf
-
Apple M1 (Apple Silicon) support
The script also creates FFmpeg on a new MacBook with an Apple Silicon M1 processor
.
LV2
plugin support
If Python is available, the script will create an ffmpeg binary with support for lv2 plugins. Continuous integration ffmpeg-build-script is
very stable. Each commit is executed against Linux and macOS with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure everything works as expected.
Requirements
macOS
- XCode 10.x or higher
Linux
- Debian >= Buster, Ubuntu => Focal Fossa, other distributions could also work
- Rocky Linux 8
- Development and curl environment required
Build on Docker (Linux)
With Docker, FFmpeg can be built reliably without altering the host system. Also, you don’t need to have the CUDA SDK installed outside of your Docker image.
Default
If you are running an operating system other than the previous one, a completely static build can work. To create a complete statically linked binary within Docker, simply run the following command:
CUDA
These builds are always compiled with the -enable-gpl-and-non-free switch, as CUDA is nonfree. See https://ffmpeg.org/legal.html
Create an export.docker file that copies only what you need from the image you just created as follows. When running, move the library library to a location where the linker can find it or set the LD_LIBRARY_PATH. Since we’ve paired the OS and version, it should work fine with dynamic links. If that doesn’t work, edit the export.docker file, copy the required libraries, and try again.
Full static version
If you are running a different operating system than the previous one, a completely static build can work. To create a complete statically linked binary within
Docker, simply run the following command: Run with Docker (macOS, Linux) You can also run the
FFmpeg directly inside a Docker container.
Default – No CUDA (macOS, Linux) If CUDA
is not required, a dockerized FFmpeg build can be run with the following command:
With CUDA
(Linux)
To
use CUDA from within the container, the installed Docker version must be >= 19.03. Install the driver and nvidia-docker2 from here. You can then run FFmpeg inside Docker with GPU hardware acceleration enabled, as follows:
Common build (macOS, Linux)
If you want to enable CUDA, check these out and install the
SDK. If you want to enable Vaapi, check these out and
install the driver
.
Cuda Installation
CUDA is a parallel computing platform developed by NVIDIA. In order to compile ffmpeg with CUDA support, you first need a compatible NVIDIA GPU.
Ubuntu: To install CUDA toolkit
- on Ubuntu, run “sudo apt install nvidia-cuda-toolkit”
- Other Linux distributions: Once you have the GPU and display driver installed, you can follow the official instructions or this blog to set up the CUDA toolkit
.
Installing Vaapi
You will need the libva driver, so install it below
.
Installation
AMF To use the
AMF encoder, you must use the AMD GPU Pro drivers that support OpenCL. Download the https://www.amd.com/en/support drivers and install the appropriate versions of opencl.
Static Link
Usage Notes
-
Due to the NSS (Name Service Switch), glibc does not recommend static bindings. See details below: https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F
-
The libnpp in the CUDA SDK
-
Vaapi cannot be statically linked.
cannot be statically linked.
- Contact Github: http://www.github.com/markus-perl/
tested on
MacOS 10.15
- Debian 10 Ubuntu 20.04
Example
Other projects of mine
- CLI Client Pushover
- A Name
- PHP Gender
- Client NPM
- Names Genderize
- API
Gender API: Genderize
Gender API Client
API
Genderize