Skip to content
Open
Show file tree
Hide file tree
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
58 changes: 50 additions & 8 deletions ffmpeg/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ if [[ -z "$PLATFORM" ]]; then
exit
fi

DISABLE="--disable-iconv --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-xlib"
DISABLE="--disable-iconv --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-libharfbuzz --enable-libopus --enable-libxml2 --enable-libsrt --enable-libwebp --enable-libaom --enable-libsvtav1 --enable-libzimg"
ENABLE_VULKAN="--enable-vulkan --enable-hwaccel=h264_vulkan --enable-hwaccel=hevc_vulkan --enable-hwaccel=av1_vulkan"
OPENCL_CONFIG="--disable-opencl"
OPENCL_CFLAGS=""
OPENCL_LDFLAGS=""
OPENCL_LIBS=""

if [[ "$EXTENSION" == *gpl ]]; then
# Enable GPLv3 modules
Expand Down Expand Up @@ -56,15 +60,15 @@ FFMPEG_VERSION=8.1.2
# with the unsupported FFmpeg 8.1 Changelog hunk already removed.
V4L2_REQUEST_PATCH=ffmpeg-v4l2-request-20847-ffmpeg-8.1.patch
download https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.gz nasm-$NASM_VERSION.tar.gz
download https://zlib.net/$ZLIB.tar.gz $ZLIB.tar.gz
download https://github.com/madler/zlib/releases/download/v${ZLIB#zlib-}/$ZLIB.tar.gz $ZLIB.tar.gz
download https://downloads.sourceforge.net/project/lame/lame/3.100/$LAME.tar.gz $LAME.tar.gz
download https://ftp.osuosl.org/pub/xiph/releases/speex/$SPEEX.tar.gz $SPEEX.tar.gz
download https://archive.mozilla.org/pub/opus/$OPUS.tar.gz $OPUS.tar.gz
download https://sourceforge.net/projects/opencore-amr/files/opencore-amr/$OPENCORE_AMR.tar.gz/download $OPENCORE_AMR.tar.gz
download https://sourceforge.net/projects/opencore-amr/files/vo-amrwbenc/$VO_AMRWBENC.tar.gz/download $VO_AMRWBENC.tar.gz
download https://www.openssl.org/source/$OPENSSL.tar.gz $OPENSSL.tar.gz
download https://github.com/cisco/openh264/archive/v$OPENH264_VERSION.tar.gz openh264-$OPENH264_VERSION.tar.gz
download https://code.videolan.org/videolan/x264/-/archive/stable/$X264.tar.gz $X264.tar.gz
download https://github.com/mirror/x264/archive/refs/heads/stable.tar.gz $X264.tar.gz
download https://github.com/videolan/x265/archive/$X265.tar.gz x265-$X265.tar.gz
download https://github.com/webmproject/libvpx/archive/v$VPX_VERSION.tar.gz libvpx-$VPX_VERSION.tar.gz
download https://ftp.osuosl.org/pub/blfs/conglomeration/alsa-lib/alsa-lib-$ALSA_VERSION.tar.bz2 alsa-lib-$ALSA_VERSION.tar.bz2
Expand All @@ -83,6 +87,35 @@ download https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMP
mkdir -p $PLATFORM$EXTENSION
cd $PLATFORM$EXTENSION
INSTALL_PATH=`pwd`
case $PLATFORM in
linux-arm64 | linux-x86_64 | macosx-arm64 | macosx-x86_64 | windows-x86_64)
OPENCL_PATH="${BUILD_PATH:-$TOP_PATH/opencl/cppbuild/$PLATFORM}"
if [[ "$PLATFORM" == windows-* ]]; then
OPENCL_PATH="$(cygpath -u "$OPENCL_PATH")"
fi
OPENCL_CONFIG="--enable-opencl"
OPENCL_CFLAGS="-I$OPENCL_PATH/include"
OPENCL_LDFLAGS="-L$OPENCL_PATH/lib"
OPENCL_LIBS="-lOpenCL"
if [[ "$PLATFORM" == linux-* ]]; then
# The ICD loader install contains only its soname. FFmpeg's
# configure probes add -lOpenCL itself.
OPENCL_LINK_PATH="$TOP_PATH/ffmpeg/cppbuild/opencl-$PLATFORM$EXTENSION"
mkdir -p "$OPENCL_LINK_PATH"
ln -sf "$OPENCL_PATH/lib/libOpenCL.so.1" "$OPENCL_LINK_PATH/libOpenCL.so"
OPENCL_LDFLAGS="-L$OPENCL_LINK_PATH $OPENCL_LDFLAGS"
elif [[ "$PLATFORM" == macosx-* ]]; then
OPENCL_LIBS="-framework OpenCL"
elif [[ "$PLATFORM" == windows-* ]]; then
if [[ ! -f "$OPENCL_PATH/include/CL/cl_d3d11.h" ]]; then
echo "Error: OpenCL D3D11 sharing header not found: $OPENCL_PATH/include/CL/cl_d3d11.h"
exit 1
fi
OPENCL_LIBS="-l:OpenCL.lib"
fi
;;
esac
DISABLE="$DISABLE $OPENCL_CONFIG"
echo "Decompressing archives..."
tar --totals -xzf ../nasm-$NASM_VERSION.tar.gz
tar --totals -xzf ../$ZLIB.tar.gz
Expand Down Expand Up @@ -138,6 +171,10 @@ sedinplace 's/CMAKE_C_COMPILER_ID MATCHES "Clang"/FALSE/g' SVT-AV1-*/CMakeLists.
sedinplace '/ANativeWindow_release/d' ffmpeg-*/libavutil/hwcontext_mediacodec.c
sedinplace 's/#define MAX_SLICES 32/#define MAX_SLICES 256/g' ffmpeg-*/libavcodec/h264dec.h

if [[ "$PLATFORM" == macosx-* && "$OPENCL_CONFIG" == "--enable-opencl" ]]; then
export DYLD_LIBRARY_PATH="$OPENCL_PATH/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
fi

case $PLATFORM in
android-arm)
export AR="$ANDROID_PREFIX-ar"
Expand Down Expand Up @@ -1136,7 +1173,7 @@ EOF
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-libdrm --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --enable-libpulse --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -lpthread -ldl -lz -lm $LIBS" || cat ffbuild/config.log
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-libdrm --enable-cuda --enable-cuvid --enable-nvenc --enable-pthreads --enable-libxcb --enable-libpulse --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $OPENCL_CFLAGS" --extra-ldflags="-L../lib/ $OPENCL_LDFLAGS" --extra-libs="-lstdc++ -lpthread -ldl -lz -lm $LIBS $OPENCL_LIBS" || cat ffbuild/config.log
make -j $MAKEJ
make install
;;
Expand Down Expand Up @@ -1556,7 +1593,7 @@ EOF
if [[ ! -d $USERLAND_PATH ]]; then
USERLAND_PATH="$(which aarch64-linux-gnu-gcc | grep -o '.*/tools/')../userland"
fi
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-omx `#--enable-mmal` --enable-omx-rpi --enable-pthreads --enable-libxcb --enable-libpulse --cc="aarch64-linux-gnu-gcc" --cxx="aarch64-linux-gnu-g++" --extra-cflags="$CFLAGS -I$USERLAND_PATH/ -I$USERLAND_PATH/interface/vmcs_host/khronos/IL/ -I$USERLAND_PATH/host_applications/linux/libs/bcm_host/include/ -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1 -fno-aggressive-loop-optimizations" --extra-ldflags="-Wl,-z,relro -L$USERLAND_PATH/build/lib/ -L../lib/" --extra-libs="-lstdc++ -lasound -lvchiq_arm `#-lvcsm` -lvcos -lpthread -ldl -lz -lm" --enable-cross-compile --arch=arm64 --target-os=linux --cross-prefix="aarch64-linux-gnu-" || cat ffbuild/config.log
LDEXEFLAGS='-Wl,-rpath,\$$ORIGIN/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-omx `#--enable-mmal` --enable-omx-rpi --enable-pthreads --enable-libxcb --enable-libpulse --cc="aarch64-linux-gnu-gcc" --cxx="aarch64-linux-gnu-g++" --extra-cflags="$CFLAGS -I$USERLAND_PATH/ -I$USERLAND_PATH/interface/vmcs_host/khronos/IL/ -I$USERLAND_PATH/host_applications/linux/libs/bcm_host/include/ -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1 $OPENCL_CFLAGS -fno-aggressive-loop-optimizations" --extra-ldflags="-Wl,-z,relro -L$USERLAND_PATH/build/lib/ -L../lib/ $OPENCL_LDFLAGS" --extra-libs="-lstdc++ -lasound -lvchiq_arm `#-lvcsm` -lvcos -lpthread -ldl -lz -lm $OPENCL_LIBS" --enable-cross-compile --arch=arm64 --target-os=linux --cross-prefix="aarch64-linux-gnu-" || cat ffbuild/config.log
make -j $MAKEJ
make install
;;
Expand Down Expand Up @@ -1970,7 +2007,7 @@ EOF
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_VULKAN --enable-pthreads --enable-indev=avfoundation --disable-libxcb --cc="clang -arch arm64" --cxx="clang++ -arch arm64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" --enable-cross-compile --arch=arm64 --target-os=darwin || cat ffbuild/config.log
LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-pthreads --enable-indev=avfoundation --disable-libxcb --cc="clang -arch arm64" --cxx="clang++ -arch arm64" --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $OPENCL_CFLAGS" --extra-ldflags="-L../lib/ $OPENCL_LDFLAGS" --extra-libs="-lstdc++ -ldl -lz -lm $OPENCL_LIBS" --enable-cross-compile --arch=arm64 --target-os=darwin || cat ffbuild/config.log
make -j $MAKEJ
make install
;;
Expand Down Expand Up @@ -2110,7 +2147,7 @@ EOF
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_VULKAN --enable-pthreads --enable-indev=avfoundation --disable-libxcb --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1" --extra-ldflags="-L../lib/" --extra-libs="-lstdc++ -ldl -lz -lm" || cat ffbuild/config.log
LDEXEFLAGS='-Wl,-rpath,@loader_path/' PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-pthreads --enable-indev=avfoundation --disable-libxcb --extra-cflags="-I../include/ -I../include/libxml2 -I../include/mfx -I../include/svt-av1 $OPENCL_CFLAGS" --extra-ldflags="-L../lib/ $OPENCL_LDFLAGS" --extra-libs="-lstdc++ -ldl -lz -lm $OPENCL_LIBS" || cat ffbuild/config.log
make -j $MAKEJ
make install
;;
Expand Down Expand Up @@ -2416,7 +2453,12 @@ EOF
make install
cd ..
cd ../ffmpeg-$FFMPEG_VERSION
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-DLIBXML_STATIC -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1" --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" || cat ffbuild/config.log
PKG_CONFIG_PATH=../lib/pkgconfig/ ./configure --prefix=.. $DISABLE $ENABLE $ENABLE_VULKAN --enable-cuda --enable-cuvid --enable-nvenc --enable-libmfx --enable-w32threads --enable-indev=dshow --target-os=mingw32 --cc="gcc -m64" --cxx="g++ -m64" --extra-cflags="-DLIBXML_STATIC -I../include/ -I../include/libxml2 -I../include/mfx/ -I../include/svt-av1 $OPENCL_CFLAGS" --extra-ldflags="-L../lib/ $OPENCL_LDFLAGS" --extra-libs="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lgcc_eh -lWs2_32 -lcrypt32 -lpthread -lz -lm -Wl,-Bdynamic -lole32 -luuid $OPENCL_LIBS" || cat ffbuild/config.log
if ! grep -q "^#define HAVE_OPENCL_D3D11 1" config.h; then
echo "Error: FFmpeg configured OpenCL without D3D11 sharing support"
cat ffbuild/config.log
exit 1
fi
make -j $MAKEJ
make install
;;
Expand Down
52 changes: 52 additions & 0 deletions ffmpeg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<name>JavaCPP Presets for FFmpeg</name>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencl</artifactId>
<version>3.1-${project.parent.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
Expand All @@ -32,6 +38,52 @@
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencl-platform</artifactId>
<version>3.1-${project.parent.version}</version>
</dependency>
</dependencies>
<configuration>
<classPaths>
<classPath>${basedir}/../opencl/target/classes/</classPath>
<classPath>${project.build.outputDirectory}</classPath>
</classPaths>
<includePaths>
<includePath>${basedir}/../opencl/target/classes/org/bytedeco/opencl/include/</includePath>
<includePath>${basedir}/../opencl/src/main/resources/org/bytedeco/opencl/include/</includePath>
<includePath>${basedir}/../opencl/cppbuild/${javacpp.platform}/include/</includePath>
<includePath>${basedir}/src/main/resources/org/bytedeco/ffmpeg/include/</includePath>
<includePath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/include/</includePath>
</includePaths>
<linkPaths>
<linkPath>${basedir}/../opencl/cppbuild/${javacpp.platform}/lib/</linkPath>
<linkPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/lib/</linkPath>
</linkPaths>
<preloadPaths>
<preloadPath>${basedir}/../opencl/cppbuild/${javacpp.platform}/bin/</preloadPath>
<preloadPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/bin/</preloadPath>
</preloadPaths>
<buildResources>
<buildResource>/${javacpp.platform.library.path}/</buildResource>
<buildResource>/org/bytedeco/opencl/${javacpp.platform}/</buildResource>
</buildResources>
<includeResources>
<includeResource>/${javacpp.platform.library.path}/include/</includeResource>
<includeResource>/org/bytedeco/opencl/include/</includeResource>
<includeResource>/org/bytedeco/opencl/${javacpp.platform}/include/</includeResource>
</includeResources>
<linkResources>
<linkResource>/${javacpp.platform.library.path}/</linkResource>
<linkResource>/${javacpp.platform.library.path}/lib/</linkResource>
<linkResource>/org/bytedeco/opencl/${javacpp.platform}/</linkResource>
<linkResource>/org/bytedeco/opencl/${javacpp.platform}/lib/</linkResource>
</linkResources>
<resourcePaths>
<resourcePath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/</resourcePath>
</resourcePaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Loading