|
|
|
|
@ -7,7 +7,7 @@ SRC_DIR="$BUILD_DIR/src"
|
|
|
|
|
INSTALL_DIR="$BUILD_DIR/install" |
|
|
|
|
JOBS=$(nproc 2>/dev/null || echo 4) |
|
|
|
|
AMF_HEADERS_VERSION="${AMF_HEADERS_VERSION:-1.5.3}" |
|
|
|
|
AMF_MARKER="$INSTALL_DIR/share/utun-ffmpeg-amf-enabled" |
|
|
|
|
FFMPEG_PROFILE_MARKER="$INSTALL_DIR/share/utun-chatgui-ffmpeg-minimal-v1" |
|
|
|
|
|
|
|
|
|
case "$(uname -s)" in |
|
|
|
|
Linux) PLATFORM=linux ;; |
|
|
|
|
@ -40,21 +40,21 @@ do_clone() {
|
|
|
|
|
# ============================================================================ |
|
|
|
|
if [ "$PLATFORM" = "linux" ]; then |
|
|
|
|
MISSING="" |
|
|
|
|
for pkg in build-essential cmake nasm pkg-config meson ninja-build git; do |
|
|
|
|
for pkg in build-essential cmake nasm pkg-config git; do |
|
|
|
|
dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg" |
|
|
|
|
done |
|
|
|
|
if [ -n "$MISSING" ]; then |
|
|
|
|
log "Installing build tools:$MISSING" |
|
|
|
|
sudo apt update -qq && sudo apt install -y $MISSING |
|
|
|
|
fi |
|
|
|
|
HW_DEPS="libva-dev libvdpau-dev" |
|
|
|
|
HW_DEPS="libva-dev libvpl-dev" |
|
|
|
|
for pkg in $HW_DEPS; do |
|
|
|
|
dpkg -s "$pkg" >/dev/null 2>&1 || { log "Installing $pkg (HW accel)"; sudo apt install -y $pkg; } |
|
|
|
|
done |
|
|
|
|
else |
|
|
|
|
check_cmd pacman |
|
|
|
|
for pkg in mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-nasm \ |
|
|
|
|
mingw-w64-ucrt-x86_64-pkg-config mingw-w64-ucrt-x86_64-meson; do |
|
|
|
|
for pkg in mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-nasm \ |
|
|
|
|
mingw-w64-ucrt-x86_64-pkg-config mingw-w64-ucrt-x86_64-libvpl; do |
|
|
|
|
pacman -Qi "$pkg" >/dev/null 2>&1 || { log "Installing $pkg"; pacman -S --noconfirm "$pkg"; } |
|
|
|
|
done |
|
|
|
|
fi |
|
|
|
|
@ -62,7 +62,6 @@ fi
|
|
|
|
|
check_cmd cmake |
|
|
|
|
check_cmd nasm |
|
|
|
|
check_cmd pkg-config |
|
|
|
|
check_cmd meson |
|
|
|
|
check_cmd git |
|
|
|
|
check_cmd curl |
|
|
|
|
|
|
|
|
|
@ -135,7 +134,7 @@ if [ ! -f "$INSTALL_DIR/lib/pkgconfig/vpx.pc" ]; then
|
|
|
|
|
cd "$SRC_DIR/libvpx" |
|
|
|
|
log "Configure libvpx..." |
|
|
|
|
./configure --prefix="$INSTALL_DIR" --enable-static --disable-shared \ |
|
|
|
|
--enable-pic --enable-vp8 --enable-vp9 --enable-vp9-highbitdepth \ |
|
|
|
|
--enable-pic --enable-vp8 --enable-vp9 --disable-vp9-highbitdepth \ |
|
|
|
|
--disable-examples --disable-tools --disable-docs --disable-unit-tests |
|
|
|
|
log "Build libvpx..." |
|
|
|
|
make -j"$JOBS" |
|
|
|
|
@ -145,24 +144,6 @@ else
|
|
|
|
|
log "Skip libvpx: already built" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# --- SVT-AV1 (fast AV1 encoder) --- |
|
|
|
|
if [ ! -f "$INSTALL_DIR/lib/pkgconfig/SvtAv1Enc.pc" ]; then |
|
|
|
|
do_clone SVT-AV1 https://gitlab.com/AOMediaCodec/SVT-AV1.git v2.3.0 |
|
|
|
|
cd "$SRC_DIR/SVT-AV1" |
|
|
|
|
mkdir -p build && cd build |
|
|
|
|
log "Configure SVT-AV1..." |
|
|
|
|
cmake .. -G "Unix Makefiles" \ |
|
|
|
|
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ |
|
|
|
|
-DBUILD_SHARED_LIBS=OFF -DBUILD_APPS=OFF \ |
|
|
|
|
-DBUILD_TESTING=OFF -DBUILD_DEC=OFF |
|
|
|
|
log "Build SVT-AV1..." |
|
|
|
|
cmake --build . -j"$JOBS" |
|
|
|
|
cmake --install . |
|
|
|
|
log "SVT-AV1 OK" |
|
|
|
|
else |
|
|
|
|
log "Skip SVT-AV1: already built" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# --- libaom (reference AV1 encoder) --- |
|
|
|
|
if [ ! -f "$INSTALL_DIR/lib/pkgconfig/aom.pc" ]; then |
|
|
|
|
do_clone libaom https://aomedia.googlesource.com/aom v3.12.0 |
|
|
|
|
@ -182,21 +163,6 @@ else
|
|
|
|
|
log "Skip libaom: already built" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# --- dav1d (fast AV1 decoder) --- |
|
|
|
|
if [ ! -f "$INSTALL_DIR/lib/pkgconfig/dav1d.pc" ]; then |
|
|
|
|
do_clone dav1d https://code.videolan.org/videolan/dav1d.git 1.5.1 |
|
|
|
|
cd "$SRC_DIR/dav1d" |
|
|
|
|
log "Configure dav1d..." |
|
|
|
|
meson setup build --prefix="$INSTALL_DIR" --buildtype release --libdir lib \ |
|
|
|
|
-Ddefault_library=static -Denable_tools=false -Denable_tests=false -Denable_docs=false |
|
|
|
|
log "Build dav1d..." |
|
|
|
|
meson compile -C build -j"$JOBS" |
|
|
|
|
meson install -C build |
|
|
|
|
log "dav1d OK" |
|
|
|
|
else |
|
|
|
|
log "Skip dav1d: already built" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# --- nv-codec-headers (NVIDIA NVENC/NVDEC headers, no build needed) --- |
|
|
|
|
if [ ! -f "$INSTALL_DIR/include/ffnvcodec/nvEncodeAPI.h" ]; then |
|
|
|
|
do_clone nv-codec-headers https://github.com/FFmpeg/nv-codec-headers.git master |
|
|
|
|
@ -229,8 +195,7 @@ if [ "$PLATFORM" = "windows" ] && [ ! -f "$INSTALL_DIR/include/AMF/core/Factory.
|
|
|
|
|
log "AMD AMF headers installed in $INSTALL_DIR/include/AMF" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
if [ -f "$INSTALL_DIR/lib/pkgconfig/libavcodec.pc" ] \ |
|
|
|
|
&& { [ "$PLATFORM" != "windows" ] || [ -f "$AMF_MARKER" ]; }; then |
|
|
|
|
if [ -f "$INSTALL_DIR/lib/pkgconfig/libavcodec.pc" ] && [ -f "$FFMPEG_PROFILE_MARKER" ]; then |
|
|
|
|
log "FFmpeg already built, skipping." |
|
|
|
|
log "Done: $INSTALL_DIR" |
|
|
|
|
exit 0 |
|
|
|
|
@ -262,25 +227,41 @@ log "Configure FFmpeg..."
|
|
|
|
|
|
|
|
|
|
CONFIGURE_ARGS=( |
|
|
|
|
--prefix="$INSTALL_DIR" |
|
|
|
|
--disable-everything --disable-network |
|
|
|
|
--enable-avcodec --enable-avformat --enable-avutil --enable-swscale --enable-swresample |
|
|
|
|
--enable-shared --disable-static |
|
|
|
|
--enable-gpl --enable-version3 |
|
|
|
|
--pkg-config-flags=--static |
|
|
|
|
--extra-cflags="-I$INSTALL_DIR/include" |
|
|
|
|
--extra-ldflags="-L$INSTALL_DIR/lib" |
|
|
|
|
--extra-libs="-lpthread -lm -ldl" |
|
|
|
|
--enable-libx264 --enable-libx265 |
|
|
|
|
--enable-libvpx --enable-libsvtav1 --enable-libaom |
|
|
|
|
--enable-libdav1d |
|
|
|
|
--enable-nvenc --enable-cuda --enable-cuvid |
|
|
|
|
--enable-vaapi --enable-vdpau |
|
|
|
|
--enable-libx264 --enable-libx265 --enable-libvpx --enable-libaom --enable-libvpl --enable-nvenc |
|
|
|
|
--enable-demuxer=avi --enable-demuxer=matroska --enable-demuxer=mov |
|
|
|
|
--enable-protocol=file --enable-parsers |
|
|
|
|
--enable-bsf=h264_mp4toannexb --enable-bsf=hevc_mp4toannexb |
|
|
|
|
--disable-programs --disable-doc --disable-avdevice |
|
|
|
|
--disable-ffprobe --disable-ffplay --disable-ffmpeg |
|
|
|
|
--disable-debug --enable-optimizations |
|
|
|
|
--disable-avfilter --disable-postproc --disable-muxers |
|
|
|
|
--disable-ffprobe --disable-ffplay --disable-ffmpeg --disable-debug --enable-optimizations |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
DECODERS=(h264 hevc av1 vp8 vp9 mpeg4 mpeg2video mpeg1video mjpeg h263 msmpeg4v3 wmv1 wmv2 vc1 |
|
|
|
|
aac mp3 opus vorbis flac ac3 eac3 alac wmav1 wmav2 pcm_s16le pcm_s24le pcm_s32le pcm_u8 pcm_f32le) |
|
|
|
|
ENCODERS=(libx264 libx265 libvpx_vp9 libaom_av1 h264_nvenc hevc_nvenc av1_nvenc |
|
|
|
|
h264_qsv hevc_qsv vp9_qsv av1_qsv) |
|
|
|
|
|
|
|
|
|
for decoder in "${DECODERS[@]}"; do CONFIGURE_ARGS+=("--enable-decoder=$decoder"); done |
|
|
|
|
for encoder in "${ENCODERS[@]}"; do CONFIGURE_ARGS+=("--enable-encoder=$encoder"); done |
|
|
|
|
|
|
|
|
|
if [ "$PLATFORM" = "windows" ]; then |
|
|
|
|
CONFIGURE_ARGS+=( |
|
|
|
|
--enable-d3d11va --enable-dxva2 --enable-amf |
|
|
|
|
--enable-amf --enable-d3d11va |
|
|
|
|
--enable-encoder=h264_amf --enable-encoder=hevc_amf --enable-encoder=av1_amf |
|
|
|
|
) |
|
|
|
|
else |
|
|
|
|
CONFIGURE_ARGS+=( |
|
|
|
|
--enable-vaapi |
|
|
|
|
--enable-encoder=h264_vaapi --enable-encoder=hevc_vaapi |
|
|
|
|
--enable-encoder=vp9_vaapi --enable-encoder=av1_vaapi |
|
|
|
|
) |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
@ -291,17 +272,15 @@ if [ "$PLATFORM" = "windows" ]; then
|
|
|
|
|
grep -Eq "^#define $encoder 1$" config_components.h \ |
|
|
|
|
|| die "FFmpeg configure did not enable $encoder; check AMF headers and config.log" |
|
|
|
|
done |
|
|
|
|
rm -f "$AMF_MARKER" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
log "Build FFmpeg..." |
|
|
|
|
make clean |
|
|
|
|
make -j"$JOBS" |
|
|
|
|
make install |
|
|
|
|
|
|
|
|
|
if [ "$PLATFORM" = "windows" ]; then |
|
|
|
|
mkdir -p "$(dirname "$AMF_MARKER")" |
|
|
|
|
touch "$AMF_MARKER" |
|
|
|
|
fi |
|
|
|
|
mkdir -p "$(dirname "$FFMPEG_PROFILE_MARKER")" |
|
|
|
|
touch "$FFMPEG_PROFILE_MARKER" |
|
|
|
|
|
|
|
|
|
log "===============================================================" |
|
|
|
|
log "FFmpeg build SUCCESS" |
|
|
|
|
|