Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add av1 codec to ffmpeg #1177

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 137 additions & 1 deletion ffmpeg/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ -z "$PLATFORM" ]]; then
fi

DISABLE="--disable-iconv --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-xlib"
ENABLE="--enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp"
ENABLE="--enable-shared --enable-version3 --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-openssl --enable-libopenh264 --enable-libvpx --enable-libfreetype --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp --enable-libaom --enable-libsvtav1"

if [[ "$EXTENSION" == *gpl ]]; then
# Enable GPLv3 modules
Expand Down Expand Up @@ -42,6 +42,8 @@ NVCODEC_VERSION=11.1.5.1
XML2=libxml2-2.9.12
LIBSRT_VERSION=1.4.4
WEBP_VERSION=1.2.2
AOMAV1_VERSION=3gpp-2021-10-15-5
SVTAV1_VERSION=1.0.0
FFMPEG_VERSION=5.0.1
download https://download.videolan.org/contrib/nasm/nasm-$NASM_VERSION.tar.gz nasm-$NASM_VERSION.tar.gz
download http://zlib.net/$ZLIB.tar.gz $ZLIB.tar.gz
Expand All @@ -62,6 +64,8 @@ download http://xmlsoft.org/sources/$XML2.tar.gz $XML2.tar.gz
download https://github.com/Haivision/srt/archive/refs/tags/v$LIBSRT_VERSION.tar.gz srt-$LIBSRT_VERSION.tar.gz
download https://github.com/FFmpeg/nv-codec-headers/archive/n$NVCODEC_VERSION.tar.gz nv-codec-headers-$NVCODEC_VERSION.tar.gz
download https://github.com/webmproject/libwebp/archive/refs/tags/v$WEBP_VERSION.tar.gz libwebp-$WEBP_VERSION.tar.gz
download https://aomedia.googlesource.com/aom/+archive/87460cef80fb03def7d97df1b47bad5432e5e2e4.tar.gz aom-$AOMAV1_VERSION.tar.gz
download https://github.com/AOMediaCodec/SVT-AV1/archive/refs/tags/v$SVTAV1_VERSION.tar.gz svt-av1-$SVTAV1_VERSION.tar.gz
download http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMPEG_VERSION.tar.bz2

mkdir -p $PLATFORM$EXTENSION
Expand All @@ -86,6 +90,8 @@ tar --totals -xzf ../mfx_dispatch-$MFX_VERSION.tar.gz
tar --totals -xzf ../nv-codec-headers-$NVCODEC_VERSION.tar.gz
tar --totals -xzf ../$XML2.tar.gz
tar --totals -xzf ../libwebp-$WEBP_VERSION.tar.gz
mkdir aom-$AOMAV1_VERSION; cd aom-$AOMAV1_VERSION; tar --totals -xzf ../../aom-$AOMAV1_VERSION.tar.gz; cd ..;
tar --totals -xzf ../svt-av1-$SVTAV1_VERSION.tar.gz
tar --totals -xjf ../ffmpeg-$FFMPEG_VERSION.tar.bz2

if [[ "${ACLOCAL_PATH:-}" == C:\\msys64\\* ]]; then
Expand Down Expand Up @@ -235,6 +241,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=arm-linux
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=arm --extra-cflags="-I../include/ -I../include/libxml2 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver
Expand Down Expand Up @@ -366,6 +382,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=aarch64-linux
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=aarch64 --extra-cflags="-I../include/ -I../include/libxml2 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver
Expand Down Expand Up @@ -494,6 +520,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=i686-linux
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=atom --extra-cflags="-I../include/ -I../include/libxml2 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver
Expand Down Expand Up @@ -621,6 +657,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=x86_64-linux
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
sedinplace 's/unsigned long int/unsigned int/g' libavdevice/v4l2.c
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' ./configure --prefix=.. $DISABLE $ENABLE --enable-jni --enable-mediacodec --enable-pthreads --enable-cross-compile --cross-prefix="$ANDROID_PREFIX-" --ar="$AR" --ranlib="$RANLIB" --cc="$CC" --strip="$STRIP" --sysroot="$ANDROID_ROOT" --target-os=android --arch=atom --extra-cflags="-I../include/ -I../include/libxml2 $ANDROID_FLAGS" --extra-ldflags="-L../lib/ $ANDROID_FLAGS" --extra-libs="$ANDROID_LIBS -lz -latomic" --disable-symver
Expand Down Expand Up @@ -747,6 +793,16 @@ EOF
fi
cd ../nv-codec-headers-n$NVCODEC_VERSION
make install PREFIX=$INSTALL_PATH
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --cc="gcc -m32 -D__ILP32__" --extra-cflags="-I../include/ -I../include/libxml2" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -lpthread -ldl -lz -lm $LIBS"
make -j $MAKEJ
Expand Down Expand Up @@ -872,6 +928,16 @@ EOF
fi
cd ../nv-codec-headers-n$NVCODEC_VERSION
make install PREFIX=$INSTALL_PATH
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --cc="gcc -m64" --extra-cflags="-I../include/ -I../include/libxml2" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -lpthread -ldl -lz -lm $LIBS"
make -j $MAKEJ
Expand Down Expand Up @@ -1045,6 +1111,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=arm-linux-gnueabihf
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
if [ $CROSSCOMPILE -eq 1 ]
then
Expand Down Expand Up @@ -1176,6 +1252,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=aarch64-linux-gnu
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
if [[ ! -d $USERLAND_PATH ]]; then
USERLAND_PATH="$(which aarch64-linux-gnu-gcc | grep -o '.*/tools/')../userland"
Expand Down Expand Up @@ -1363,6 +1449,16 @@ EOF
fi
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
if [[ "$MACHINE_TYPE" =~ ppc64 ]]; then
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-pthreads --enable-libxcb --cc="gcc -m64" --extra-cflags="-I../include/ -I../include/libxml2" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" --disable-altivec
Expand Down Expand Up @@ -1480,6 +1576,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic --host=aarch64-apple-darwin
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
patch -Np1 < ../../../ffmpeg-macosx.patch
LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-pthreads --enable-indev=avfoundation --disable-libxcb --cc="clang -arch arm64" --extra-cflags="-I../include/ -I../include/libxml2" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" --enable-cross-compile --arch=arm64 --target-os=darwin
Expand Down Expand Up @@ -1590,6 +1696,16 @@ EOF
./configure --prefix=$INSTALL_PATH --with-bzip2=no --with-harfbuzz=no --with-png=no --with-brotli=no --enable-static --disable-shared --with-pic
make -j $MAKEJ
make install
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
patch -Np1 < ../../../ffmpeg-macosx.patch
LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-pthreads --enable-indev=avfoundation --disable-libxcb --extra-cflags="-I../include/ -I../include/libxml2" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm"
Expand Down Expand Up @@ -1708,6 +1824,16 @@ EOF
make install
cd ../nv-codec-headers-n$NVCODEC_VERSION
make install PREFIX=$INSTALL_PATH
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m32" --extra-cflags="-DLIBXML_STATIC -I../include/ -I../include/libxml2/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid"
make -j $MAKEJ
Expand Down Expand Up @@ -1825,6 +1951,16 @@ EOF
make install
cd ../nv-codec-headers-n$NVCODEC_VERSION
make install PREFIX=$INSTALL_PATH
cd ../aom-$AOMAV1_VERSION; mkdir build_release; cd build_release
CC="gcc -m64" CXX="g++ -m64" $CMAKE -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../svt-av1-$SVTAV1_VERSION; mkdir build_release; cd build_release
CC="gcc -m64" CXX="g++ -m64" $CMAKE -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Release ..
make -j $MAKEJ
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --extra-cflags="-DLIBXML_STATIC -I../include/ -I../include/libxml2/" --extra-ldflags="-L../lib/" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid"
make -j $MAKEJ
Expand Down