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

Enable chromaprint in ffmpeg #150

Merged
merged 3 commits into from
May 29, 2022
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ENV DPKG_INSTALL_LIST=${SOURCE_DIR}/debian/jellyfin-ffmpeg5.install
ENV PATH=${TARGET_DIR}/bin:${PATH}
ENV PKG_CONFIG_PATH=${TARGET_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}
ENV LD_LIBRARY_PATH=${TARGET_DIR}/lib:${TARGET_DIR}/lib/mfx:${TARGET_DIR}/lib/xorg:${LD_LIBRARY_PATH}
ENV LDFLAGS=-Wl,-rpath=${TARGET_DIR}/lib
ENV LDFLAGS="-Wl,-rpath=${TARGET_DIR}/lib -L${TARGET_DIR}/lib"
ENV CXXFLAGS="-I${TARGET_DIR}/include $CXXFLAGS"
ENV CPPFLAGS="-I${TARGET_DIR}/include $CPPFLAGS"
ENV CFLAGS="-I${TARGET_DIR}/include $CFLAGS"
Expand Down
2 changes: 1 addition & 1 deletion build-win64
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ done

# Use the latest distro for toolchains
distro="ubuntu:jammy"
ffrevison="4"
ffrevison="5"
image_name="jellyfin-ffmpeg-build-windows-win64"
package_temporary_dir="$( mktemp -d )"
current_user="$( whoami )"
Expand Down
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# We just wrap `build` so this is really it
name: "jellyfin-ffmpeg"
version: "5.0.1-4"
version: "5.0.1-5"
packages:
- buster-amd64
- buster-armhf
Expand Down
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
jellyfin-ffmpeg (5.0.1-5) unstable; urgency=medium

* Enable chromaprint.
* Update dependencies.
* Fix the issue that SPS/PPS are lost on AMD VCN H264 encoder.

-- nyanmisaka <[email protected]> Thu, 26 May 2022 20:13:31 +0800

jellyfin-ffmpeg (5.0.1-4) unstable; urgency=medium

* Add hevc dovi support for hlsenc.
Expand Down
2 changes: 2 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PACKAGEVERSION := "$(ORIG_VERSION)-$(VERSION_SUFFIX)"

CONFIG := --prefix=${TARGET_DIR} \
--target-os=linux \
--extra-libs='-lfftw3' \
--extra-version=Jellyfin \
--disable-doc \
--disable-ffplay \
Expand All @@ -26,6 +27,7 @@ CONFIG := --prefix=${TARGET_DIR} \
--enable-static \
--enable-gmp \
--enable-gnutls \
--enable-chromaprint \
--enable-libdrm \
--enable-libass \
--enable-libfreetype \
Expand Down
45 changes: 45 additions & 0 deletions docker-build-win64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,48 @@ make install
popd
popd

# FFTW3
mkdir fftw3
pushd fftw3
fftw3_ver="3.3.10"
fftw3_link="https://fftw.org/fftw-${fftw3_ver}.tar.gz"
wget ${fftw3_link} -O fftw3.tar.gz
tar xaf fftw3.tar.gz
pushd fftw-${fftw3_ver}
./configure \
--prefix=${FF_DEPS_PREFIX} \
--host=${FF_TOOLCHAIN} \
--disable-{shared,doc} \
--enable-{static,threads,fortran} \
--enable-{sse2,avx,avx-128-fma,avx2,avx512} \
--with-our-malloc \
--with-combined-threads \
--with-incoming-stack-boundary=2
make -j$(nproc)
make install
popd
popd

# CHROMAPRINT
git clone --depth=1 https://github.com/acoustid/chromaprint.git
pushd chromaprint
mkdir build
pushd build
cmake \
-DCMAKE_TOOLCHAIN_FILE=${FF_CMAKE_TOOLCHAIN} \
-DCMAKE_INSTALL_PREFIX=${FF_DEPS_PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_{TOOLS,TESTS}=OFF \
-DFFT_LIB=fftw3 \
..
make -j$(nproc)
make install
FF_EXTRA_LIBS="-lfftw3 -lstdc++${FF_EXTRA_LIBS}"
FF_EXTRA_CFLAGS="-DCHROMAPRINT_NODLL${FF_EXTRA_CFLAGS}"
popd
popd

# LZMA
mkdir xz
pushd xz
Expand Down Expand Up @@ -508,6 +550,8 @@ fi
./configure \
--prefix=${FF_PREFIX} \
${FF_TARGET_FLAGS} \
--extra-libs="${FF_EXTRA_LIBS}" \
--extra-cflags="${FF_EXTRA_CFLAGS}" \
--extra-version=Jellyfin \
--disable-ffplay \
--disable-debug \
Expand All @@ -526,6 +570,7 @@ fi
--enable-zlib \
--enable-lzma \
--enable-gmp \
--enable-chromaprint \
--enable-libfreetype \
--enable-libfribidi \
--enable-libfontconfig \
Expand Down
128 changes: 87 additions & 41 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,77 @@ PORTS_ADDR=http://ports.ubuntu.com/

# Prepare common extra libs for amd64, armhf and arm64
prepare_extra_common() {
# ZIMG
pushd ${SOURCE_DIR}
git clone --depth=1 https://github.com/sekrit-twc/zimg
pushd zimg
case ${ARCH} in
'amd64')
CROSS_OPT=""
CMAKE_TOOLCHAIN_OPT=""
MESON_CROSS_OPT=""
;;
'armhf')
CROSS_OPT="--host=armv7-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++"
CMAKE_TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=${SOURCE_DIR}/toolchain-${ARCH}.cmake"
MESON_CROSS_OPT="--cross-file=${SOURCE_DIR}/cross-${ARCH}.meson"
;;
'arm64')
CROSS_OPT="--host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++"
CMAKE_TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=${SOURCE_DIR}/toolchain-${ARCH}.cmake"
MESON_CROSS_OPT="--cross-file=${SOURCE_DIR}/cross-${ARCH}.meson"
;;
esac

# FFTW3
pushd ${SOURCE_DIR}
mkdir fftw3
pushd fftw3
fftw3_ver="3.3.10"
fftw3_link="https://fftw.org/fftw-${fftw3_ver}.tar.gz"
wget ${fftw3_link} -O fftw3.tar.gz
tar xaf fftw3.tar.gz
pushd fftw-${fftw3_ver}
if [ "${ARCH}" = "amd64" ]; then
fftw3_optimizations="--enable-sse2 --enable-avx --enable-avx-128-fma --enable-avx2 --enable-avx512"
else
fftw3_optimizations=""
fi
./configure \
${CROSS_OPT} \
--prefix=${TARGET_DIR} \
--disable-{static,doc} \
--enable-{shared,threads,fortran} \
$fftw3_optimizations \
--with-our-malloc \
--with-combined-threads \
--with-incoming-stack-boundary=2
make -j$(nproc) && make install && make install DESTDIR=${SOURCE_DIR}/fftw3
echo "fftw3${TARGET_DIR}/lib/libfftw3.so* usr/lib/jellyfin-ffmpeg/lib" >> ${DPKG_INSTALL_LIST}
popd
popd
popd

# CHROMAPRINT
pushd ${SOURCE_DIR}
git clone --depth=1 https://github.com/acoustid/chromaprint.git
pushd chromaprint
mkdir build
pushd build
cmake \
${CMAKE_TOOLCHAIN_OPT} \
-DCMAKE_INSTALL_PREFIX=${TARGET_DIR} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_{TOOLS,TESTS}=OFF \
-DFFT_LIB=fftw3 \
..
make -j$(nproc) && make install && make install DESTDIR=${SOURCE_DIR}/chromaprint
echo "chromaprint${TARGET_DIR}/lib/libchromaprint.so* usr/lib/jellyfin-ffmpeg/lib" >> ${DPKG_INSTALL_LIST}
popd
popd
popd

# ZIMG
pushd ${SOURCE_DIR}
git clone --depth=1 https://github.com/sekrit-twc/zimg
pushd zimg
./autogen.sh
./configure --prefix=${TARGET_DIR} ${CROSS_OPT}
make -j $(nproc) && make install && make install DESTDIR=${SOURCE_DIR}/zimg
Expand All @@ -35,39 +91,29 @@ prepare_extra_common() {
# DAV1D
pushd ${SOURCE_DIR}
git clone -b 1.0.0 --depth=1 https://code.videolan.org/videolan/dav1d.git
nasmver="$(nasm -v | cut -d ' ' -f3)"
nasmminver="2.14.0"
if [ "$(printf '%s\n' "$nasmminver" "$nasmver" | sort -V | head -n1)" = "$nasmminver" ]; then
x86asm=true
else
x86asm=false
fi
if [ "${ARCH}" = "amd64" ]; then
meson setup dav1d dav1d_build \
--prefix=${TARGET_DIR} \
--libdir=lib \
-Ddefault_library=shared \
-Denable_asm=$x86asm \
-Denable_{tools,tests,examples}=false
meson configure dav1d_build
ninja -C dav1d_build install
cp ${TARGET_DIR}/lib/libdav1d.so* ${SOURCE_DIR}/dav1d
echo "dav1d/libdav1d.so* /usr/lib/jellyfin-ffmpeg/lib" >> ${DPKG_INSTALL_LIST}
fi
if [ "${ARCH}" = "armhf" ] || [ "${ARCH}" = "arm64" ]; then
meson setup dav1d dav1d_build \
--cross-file=${SOURCE_DIR}/cross-${ARCH}.meson \
--prefix=${TARGET_DIR} \
--libdir=lib \
--buildtype=release \
-Ddefault_library=shared \
-Denable_asm=true \
-Denable_{tools,tests,examples}=false
meson configure dav1d_build
ninja -C dav1d_build install
cp ${TARGET_DIR}/lib/libdav1d.so* ${SOURCE_DIR}/dav1d
echo "dav1d/libdav1d.so* /usr/lib/jellyfin-ffmpeg/lib" >> ${DPKG_INSTALL_LIST}
nasmver="$(nasm -v | cut -d ' ' -f3)"
nasmminver="2.14.0"
if [ "$(printf '%s\n' "$nasmminver" "$nasmver" | sort -V | head -n1)" = "$nasmminver" ]; then
dav1d_asm=true
else
dav1d_asm=false
fi
else
dav1d_asm=true
fi
meson setup dav1d dav1d_build \
${MESON_CROSS_OPT} \
--prefix=${TARGET_DIR} \
--libdir=lib \
--buildtype=release \
-Ddefault_library=shared \
-Denable_asm=$dav1d_asm \
-Denable_{tools,tests,examples}=false
meson configure dav1d_build
ninja -C dav1d_build install
cp ${TARGET_DIR}/lib/libdav1d.so* ${SOURCE_DIR}/dav1d
echo "dav1d/libdav1d.so* /usr/lib/jellyfin-ffmpeg/lib" >> ${DPKG_INSTALL_LIST}
popd

# FDK-AAC-STRIPPED
Expand Down Expand Up @@ -178,7 +224,7 @@ prepare_extra_amd64() {
# Provides MSDK runtime (libmfxhw64.so.1) for 11th Gen Rocket Lake and older
# Provides MFX dispatcher (libmfx.so.1) for FFmpeg
pushd ${SOURCE_DIR}
git clone -b intel-mediasdk-22.4.1 --depth=1 https://github.com/Intel-Media-SDK/MediaSDK
git clone -b intel-mediasdk-22.4.2 --depth=1 https://github.com/Intel-Media-SDK/MediaSDK
pushd MediaSDK
sed -i 's|MFX_PLUGINS_CONF_DIR "/plugins.cfg"|"/usr/lib/jellyfin-ffmpeg/lib/mfx/plugins.cfg"|g' api/mfx_dispatch/linux/mfxloader.cpp
mkdir build && pushd build
Expand All @@ -198,7 +244,7 @@ prepare_extra_amd64() {
# Provides VPL runtime (libmfx-gen.so.1.2) for 11th Gen Tiger Lake and newer
# Both MSDK and VPL runtime can be loaded by MFX dispatcher (libmfx.so.1)
pushd ${SOURCE_DIR}
git clone -b intel-onevpl-22.4.1 --depth=1 https://github.com/oneapi-src/oneVPL-intel-gpu
git clone -b intel-onevpl-22.4.2 --depth=1 https://github.com/oneapi-src/oneVPL-intel-gpu
pushd oneVPL-intel-gpu
mkdir build && pushd build
cmake -DCMAKE_INSTALL_PREFIX=${TARGET_DIR} ..
Expand All @@ -212,7 +258,7 @@ prepare_extra_amd64() {
# Full Feature Build: ENABLE_KERNELS=ON(Default) ENABLE_NONFREE_KERNELS=ON(Default)
# Free Kernel Build: ENABLE_KERNELS=ON ENABLE_NONFREE_KERNELS=OFF
pushd ${SOURCE_DIR}
git clone -b intel-media-22.4.1 --depth=1 https://github.com/intel/media-driver
git clone -b intel-media-22.4.2 --depth=1 https://github.com/intel/media-driver
pushd media-driver
sed -i 's|find_package(X11)||g' media_softlet/media_top_cmake.cmake media_driver/media_top_cmake.cmake
mkdir build && pushd build
Expand All @@ -232,7 +278,7 @@ prepare_extra_amd64() {

# Vulkan Headers
pushd ${SOURCE_DIR}
git clone -b v1.3.213 --depth=1 https://github.com/KhronosGroup/Vulkan-Headers
git clone -b v1.3.215 --depth=1 https://github.com/KhronosGroup/Vulkan-Headers
pushd Vulkan-Headers
mkdir build && pushd build
cmake \
Expand All @@ -245,7 +291,7 @@ prepare_extra_amd64() {

# Vulkan ICD Loader
pushd ${SOURCE_DIR}
git clone -b v1.3.213 --depth=1 https://github.com/KhronosGroup/Vulkan-Loader
git clone -b v1.3.215 --depth=1 https://github.com/KhronosGroup/Vulkan-Loader
pushd Vulkan-Loader
mkdir build && pushd build
cmake \
Expand Down Expand Up @@ -294,7 +340,7 @@ prepare_extra_amd64() {
# llvm >= 11
apt-get install -y llvm-11-dev
pushd ${SOURCE_DIR}
git clone -b mesa-22.0.3 --depth=1 https://gitlab.freedesktop.org/mesa/mesa.git
git clone -b mesa-22.0.4 --depth=1 https://gitlab.freedesktop.org/mesa/mesa.git
# disable the broken hevc packed header
MESA_VA_PIC=mesa/src/gallium/frontends/va/picture.c
MESA_VA_CONF=mesa/src/gallium/frontends/va/config.c
Expand Down
13 changes: 13 additions & 0 deletions toolchain-arm64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_RANLIB aarch64-linux-gnu-ranlib)
set(CMAKE_AR aarch64-linux-gnu-ar)

set(CMAKE_FIND_ROOT_PATH /usr/bin /usr/lib/jellyfin-ffmpeg /usr/aarch64-linux-gnu)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13 changes: 13 additions & 0 deletions toolchain-armhf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7)

set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_RANLIB arm-linux-gnueabihf-ranlib)
set(CMAKE_AR arm-linux-gnueabihf-ar)

set(CMAKE_FIND_ROOT_PATH /usr/bin /usr/lib/jellyfin-ffmpeg /usr/arm-linux-gnueabihf)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)