This script was made to compile FFmpeg with common codecs on Linux and macOS by Martin Riedl @martinr92 , I made the FFmpeg compiled by this script a shared one, with PGO and LTO optimization (currently only for x265 and SVT-AV1), focus on using it directly by CLI and the best performance as possible.
This script is currently not compatible with Linux, because of the difference of sed's syntax, clang/gnu, and the behavior of CMake. I will try to work on it later after finishing my main development goals.
Check out the build server. Here you can download builds for Linux and macOS.
This repository builds FFmpeg, FFprobe and FFplay using
- build tools
- libraries
- libass for subtitle rendering
- libbluray for container format bluray
- decklink
- fontconfig
- FreeType
- FriBidi
- harfbuzz
- libiconv
- libklvanc
- libogg for container format ogg
- openssl
- SDL for ffplay
- snappy for HAP encoding
- srt for protocol srt
- libvmaf for VMAF video filter
- libxml2
- zimg
- zlib for png format
- zvbi for teletext decoding
- video codecs
- aom for AV1 de-/encoding
- dav1d for AV1 decoding
- openh264 for H.264 de-/encoding
- OpenJPEG for JPEG de-/encoding
- rav1e for AV1 encoding
- svt-av1 for AV1 encoding
- libtheroa for theora encoding
- vpx for VP8/VP9 de-/encoding
- libwebp for webp encoding
- x264 for H.264 encoding
- x265 for H.265/HEVC encoding (8bit+10bit+12bit)
- audio codecs
To get a full list of all formats and codecs that are supported just execute
./ffmpeg -formats
./ffmpeg -codecs
There are just a few dependencies to other tools. Most of the software is compiled or downloaded during script execution. Also most of the tools should be already available on the system by default.
- gcc (c and c++ compiler)
- curl
- make
- zip, bunzip2
- rust / cargo / cargo-c
- python3 (including pip virtualenv)
- Xcode
- rust / cargo / cargo-c
- python3 (including pip virtualenv)
For compilation on Windows please use MSYS2
. Follow the whole instructions for installation (including step 7).
All files that are downloaded and generated through this script are placed in the current working directory. The recommendation is to use an empty folder for this and execute the build.sh
.
mkdir ffmpeg-compile
cd ffmpeg-compile
../build.sh
You can use the following parameters
-FFMPEG_SNAPSHOT=YES
for using the latest snapshot of FFmpeg instead of the last release-SKIP_TEST=YES
for skipping the tests after compiling-SKIP_BUNDLE=YES
for skipping creating theffmpeg-success.zip
file-CPU_LIMIT=num
for limit CPU thread usage (default: automatically detected)
If you don't need a codec/library, you can also disable them:
- libraries
-SKIP_LIBKLVANC=YES
-SKIP_LIBBLURAY=YES
-SKIP_SNAPPY=YES
-SKIP_SRT=YES
-SKIP_LIBVMAF=YES
-SKIP_ZIMG=YES
-SKIP_ZVBI=YES
- video codecs
-SKIP_AOM=YES
-SKIP_DAV1D=YES
-SKIP_OPEN_H264=YES
-SKIP_OPEN_JPEG=YES
-SKIP_RAV1E=YES
-SKIP_SVT_AV1=YES
-SKIP_LIBTHEORA=YES
-SKIP_VPX=YES
-SKIP_LIBWEBP=YES
-SKIP_X264=YES
-SKIP_X265=YES
-SKIP_X265_MULTIBIT=YES
- audio codecs
-SKIP_LAME=YES
-SKIP_OPUS=YES
-SKIP_LIBVORBIS=YES
After the execution a new folder called out
exists. It contains the compiled FFmpeg binary (in the bin
sub-folder).
The ffmpeg-success.zip
contains also all binary files of FFmpeg, FFprobe and FFplay.
It is required to prepare the Blackmagic Decklink SDK manually, because a automated download is not possible. Download the SDK manually from the Blackmagic Website and extract the compressed file. Then add the following parameters (for the SDK include location):
-DECKLINK_SDK=/path/to/SDK/os/include -SKIP_DECKLINK=NO
You can check dynamically linked libraries using the follwing command:
# macOS
otool -L out/bin/ffmpeg
# linux
ldd out/bin/ffmpeg
Check the detailed logfiles in the log
directory. Each build step has its own file starting with "build-*".
If the build of ffmpeg failes during the configuration phase (e.g. because it doesn't find one codec) check also the log file in source/ffmpeg/ffmpeg-*/ffbuild/config.log
.
Copyright 2021 Martin Riedl Copyright 2024 Hayden Zheng
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.