diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc0efb7e..09332739 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - name: build ffmpeg run: | while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build + SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build --enable-gpl-and-non-free kill %1 - name: check shared library run: | @@ -45,7 +45,7 @@ jobs: - name: build ffmpeg run: | while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done & - SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build + SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build --enable-gpl-and-non-free kill %1 - name: check shared library run: | diff --git a/README.md b/README.md index 923bd903..88607a95 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ build-ffmpeg ========== -The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with **non-freecodecs** included. +The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS** and **Linux** with optional **non-free and GPL codecs** (--enable-gpl-and-non-free) included. [![How-To build FFmpeg on MacOS](https://img.youtube.com/vi/Z9p3mM757cM/0.jpg)](https://www.youtube.com/watch?v=Z9p3mM757cM "How-To build FFmpeg on OSX") @@ -16,8 +16,8 @@ The FFmpeg build script provides an easy way to build a static FFmpeg on **macOS ## Disclaimer And Data Privacy Notice This script will download different packages with different licenses from various sources, which may track your usage. -These sources are out of control by the developers of this script. Also, this script creates a non-free and unredistributable binary. By downloading and using this script, you are fully -aware of this. +These sources are out of control by the developers of this script. Also, this script can create a non-free and unredistributable binary. +By downloading and using this script, you are fully aware of this. Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems other than Debian 10 and macOS 11.x, because I don't have the resources or time to maintain different systems. @@ -126,38 +126,35 @@ $ sudo dnf install @development-tools curl With Docker, FFmpeg can be built reliably without altering the host system. Also, there is no need to have the CUDA SDK installed outside of the Docker image. -A Docker engine with version 19.03 or higher is required to build images based on the following distributions: +##### Default -* Ubuntu >= 16.04 (16.04, 18.04, 20.04) -* Centos >= 7 (7, 8) - -1. Enable Docker BuildKit +If you're running an operating system other than the one above, a completely static build may work. To build a full +statically linked binary inside Docker, just run the following command: ```bash -$ export DOCKER_BUILDKIT=1 +$ docker build --tag=ffmpeg:default --output type=local,dest=build -f Dockerfile . ``` -2. Set the DIST (`ubuntu` or `centos`) and VER (ubuntu: `16.04` , `18.04`, `20.04` or centos: `7`, `8`) environment - variables to select the preferred Docker base image. - +##### CUDA +These builds are always built with the --enable-gpl-and-non-free switch, as CUDA is non-free. See https://ffmpeg.org/legal.html ```bash +export DOCKER_BUILDKIT=1 + +## Set the DIST (`ubuntu` or `centos`) and VER (ubuntu: `16.04` , `18.04`, `20.04` or centos: `7`, `8`) environment variables to select the preferred Docker base image. $ export DIST=centos $ export VER=8 -``` -3. Start the build as follows. - -```bash -$ sudo -E docker build --tag=ffmpeg:cuda-$DIST -f cuda-$DIST.dockerfile --build-arg VER=$VER . +## Start the build +$ docker build --tag=ffmpeg:cuda-$DIST -f cuda-$DIST.dockerfile --build-arg VER=$VER . ``` -4. Build an `export.dockerfile` that copies only what you need from the image you just built as follows. When running, - move the library in the lib to a location where the linker can find it or set the `LD_LIBRARY_PATH`. Since we have - matched the operating system and version, it should work well with dynamic links. If it doesn't work, edit - the `export.dockerfile` and copy the necessary libraries and try again. +Build an `export.dockerfile` that copies only what you need from the image you just built as follows. When running, +move the library in the lib to a location where the linker can find it or set the `LD_LIBRARY_PATH`. Since we have +matched the operating system and version, it should work well with dynamic links. If it doesn't work, edit +the `export.dockerfile` and copy the necessary libraries and try again. ```bash -$ sudo -E docker build --output type=local,dest=build -f export.dockerfile --build-arg DIST=$DIST . +$ docker build --output type=local,dest=build -f export.dockerfile --build-arg DIST=$DIST . $ ls build bin lib $ ls build/bin @@ -166,7 +163,7 @@ $ ls build/lib libnppc.so.11 libnppicc.so.11 libnppidei.so.11 libnppig.so.11 ``` -### Build in Docker (full static ver.) (Linux) +##### Full static version If you're running an operating system other than the one above, a completely static build may work. To build a full statically linked binary inside Docker, just run the following command: @@ -238,12 +235,13 @@ $ sudo dnf install libva-devel libva-intel-driver libva-utils ```bash Usage: build-ffmpeg [OPTIONS] Options: - -h, --help Display usage information - --version Display version information - -b, --build Starts the build process - -c, --cleanup Remove all working dirs - -f, --full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux** - Note: Because of the NSS (Name Service Switch), glibc does not recommend static links. + -h, --help Display usage information + --version Display version information + -b, --build Starts the build process + --enable-gpl-and-non-free Enable non-free codecs - https://ffmpeg.org/legal.html + -c, --cleanup Remove all working dirs + --full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux** + Note: Because of the NSS (Name Service Switch), glibc does not recommend static links. ``` ## Notes of static link diff --git a/build-ffmpeg b/build-ffmpeg index c47ad2fd..8f0357c0 100755 --- a/build-ffmpeg +++ b/build-ffmpeg @@ -4,7 +4,7 @@ # LICENSE: https://github.com/markus-perl/ffmpeg-build-script/blob/master/LICENSE PROGNAME=$(basename "$0") -VERSION=1.23 +VERSION=1.24 CWD=$(pwd) PACKAGES="$CWD/packages" WORKSPACE="$CWD/workspace" @@ -14,6 +14,8 @@ LDEXEFLAGS="" EXTRALIBS="-ldl -lpthread -lm -lz" MACOS_M1=false CONFIGURE_OPTIONS=() +NONFREE_AND_GPL=false + # Check for Apple Silicon if [[ ("$(uname -m)" == "arm64") && ("$OSTYPE" == "darwin"*) ]]; then # If arm64 AND darwin (macOS) @@ -182,12 +184,13 @@ cleanup() { usage() { echo "Usage: $PROGNAME [OPTIONS]" echo "Options:" - echo " -h, --help Display usage information" - echo " --version Display version information" - echo " -b, --build Starts the build process" - echo " -c, --cleanup Remove all working dirs" - echo " -f, --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" - echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." + echo " -h, --help Display usage information" + echo " --version Display version information" + echo " -b, --build Starts the build process" + echo " --enable-gpl-and-non-free Enable GPL and non-free codecs - https://ffmpeg.org/legal.html" + echo " -c, --cleanup Remove all working dirs" + echo " --full-static Build a full static FFmpeg binary (eg. glibc, pthreads etc...) **only Linux**" + echo " Note: Because of the NSS (Name Service Switch), glibc does not recommend static links." echo "" } @@ -202,14 +205,19 @@ while (($# > 0)); do exit 0 ;; -*) - if [[ "$1" == "--build" || "$1" =~ 'b' ]]; then + if [[ "$1" == "--build" || "$1" =~ '-b' ]]; then bflag='-b' fi - if [[ "$1" == "--cleanup" || "$1" =~ 'c' && ! "$1" =~ '--' ]]; then + if [[ "$1" == "--enable-gpl-and-non-free" ]]; then + CONFIGURE_OPTIONS+=("--enable-nonfree") + CONFIGURE_OPTIONS+=("--enable-gpl") + NONFREE_AND_GPL=true + fi + if [[ "$1" == "--cleanup" || "$1" =~ '-c' && ! "$1" =~ '--' ]]; then cflag='-c' cleanup fi - if [[ "$1" == "--full-static" || "$1" =~ 'f' ]]; then + if [[ "$1" == "--full-static" ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then echo "Error: A full static binary can only be build on Linux." exit 1 @@ -373,6 +381,7 @@ if build "zlib"; then build_done "zlib" fi +if $NONFREE_AND_GPL; then if build "openssl"; then download "https://www.openssl.org/source/openssl-1.1.1i.tar.gz" if $MACOS_M1; then @@ -386,10 +395,12 @@ if build "openssl"; then build_done "openssl" fi CONFIGURE_OPTIONS+=("--enable-openssl") +fi if build "cmake"; then download "https://cmake.org/files/v3.18/cmake-3.18.4.tar.gz" - execute ./configure --prefix="${WORKSPACE}" --system-zlib + execute ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF + execute ./configure --prefix="${WORKSPACE}" execute make -j $MJOBS execute make install build_done "cmake" @@ -409,10 +420,7 @@ if ! $MACOS_M1; then CONFIGURE_OPTIONS+=("--enable-libsvtav1") fi -## -## video library -## - +if $NONFREE_AND_GPL; then if build "x264"; then download "https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" "x264-0d754ec.tar.gz" cd "${PACKAGES}"/x264-0d754ec || exit @@ -430,7 +438,9 @@ if build "x264"; then build_done "x264" fi CONFIGURE_OPTIONS+=("--enable-libx264") +fi +if $NONFREE_AND_GPL; then if build "x265"; then download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" cd build/linux || exit @@ -446,6 +456,7 @@ if build "x265"; then build_done "x265" fi CONFIGURE_OPTIONS+=("--enable-libx265") +fi if build "libvpx"; then download "https://github.com/webmproject/libvpx/archive/v1.9.0.tar.gz" "libvpx-1.9.0.tar.gz" @@ -464,6 +475,7 @@ if build "libvpx"; then fi CONFIGURE_OPTIONS+=("--enable-libvpx") +if $NONFREE_AND_GPL; then if build "xvidcore"; then download "https://downloads.xvid.com/downloads/xvidcore-1.3.7.tar.gz" cd build/generic || exit @@ -482,12 +494,13 @@ if build "xvidcore"; then build_done "xvidcore" fi CONFIGURE_OPTIONS+=("--enable-libxvid") +fi +if $NONFREE_AND_GPL; then if build "vid_stab"; then download "https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" "vid.stab-1.1.0.tar.gz" if $MACOS_M1; then - curl -s -o "$PACKAGES/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch patch -p1 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy