From 0624f02dc40de2da9cc11cb30427a6ac16639ef6 Mon Sep 17 00:00:00 2001 From: barts Date: Wed, 24 Jan 2024 20:49:30 +0100 Subject: [PATCH] CI: added libva to release --- README.md | 1 + cmake/Find.cmake | 15 +++++++++++++-- scripts/build-ffmpeg | 14 +++++++++++--- scripts/build-libva | 28 +++++++++++++++++++++++----- src/CMakeLists.txt | 21 +++++++++++++-------- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f2c53f1..e55460f 100644 --- a/README.md +++ b/README.md @@ -421,6 +421,7 @@ more information. - [ ] Cross compile for raspberry pi - [ ] Segmentation fault when running --record without a camera being available. +- [ ] Fix release workflow such that it links libva correctly to static ffmpeg. - [ ] Fix issue with ffmpeg + hw acceleration on my arch machine: ``` diff --git a/cmake/Find.cmake b/cmake/Find.cmake index b1cd6d7..e032ce4 100644 --- a/cmake/Find.cmake +++ b/cmake/Find.cmake @@ -86,14 +86,25 @@ function(find_libva) set(libva_shorts va va-drm va-wayland va-x11) set(libva_longs LIBVA_LIBRARY LIBVA_DRM_LIBRARY LIBVA_WAYLAND_LIBRARY LIBVA_X11_LIBRARY) + if(LIBVA_DIR) + message(STATUS "LIBVA_DIR: ${LIBVA_DIR}") + set(find_args PATHS ${LIBVA_DIR} NO_DEFAULT_PATH) + endif() find_libdrm() - find_path(LIBVA_INCLUDE_DIR NAMES va/va.h) + find_path( + LIBVA_INCLUDE_DIR + NAMES va/va.h + PATH_SUFFIXES include ${find_args}) + message(STATUS "LIBVA_INCLUDE_DIR: ${LIBVA_INCLUDE_DIR}") foreach(libva_short ${libva_shorts}) _short2long(${libva_short}) # creates libva_long - find_library(${libva_long} NAMES ${libva_short}) + find_library( + ${libva_long} + NAMES ${libva_short} + PATH_SUFFIXES lib ${find_args}) add_library(Libva::${libva_short} UNKNOWN IMPORTED) set_target_properties( Libva::${libva_short} diff --git a/scripts/build-ffmpeg b/scripts/build-ffmpeg index fe05648..17e0f6a 100755 --- a/scripts/build-ffmpeg +++ b/scripts/build-ffmpeg @@ -56,7 +56,7 @@ install_dependencies_apt() { echo "Updating apt-get" sudo apt-get update -qq echo "Installing build tools and dependencies" - sudo apt-get -y install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev gnutls-bin libunistring-dev libaom-dev libdav1d-dev tar + sudo apt-get -y install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev gnutls-bin libunistring-dev libaom-dev libdav1d-dev tar echo "Installing ffmpeg dependencies" sudo apt-get -y install nasm libx264-dev libx265-dev libvpx-dev libfdk-aac-dev libopus-dev libdav1d-dev libnuma-dev @@ -64,10 +64,17 @@ install_dependencies_apt() { install_dependencies_pacman() { echo "Installing build tools and dependencies" - sudo pacman -S --noconfirm --needed autoconf automake cmake git libass freetype2 sdl2 libtool libva libvdpau libvorbis libxcb meson ninja pkgconf texinfo wget yasm zlib gnutls libunistring aom dav1d tar + sudo pacman -S --noconfirm autoconf automake cmake git libass freetype2 sdl2 libtool libvdpau libvorbis libxcb meson ninja pkgconf texinfo wget yasm gnutls libunistring aom dav1d tar + sudo pacman -S --noconfirm zlib || true echo "Installing ffmpeg dependencies" - sudo pacman -S --noconfirm --needed nasm x264 x265 libvpx fdkaac opus numactl + sudo pacman -S --noconfirm nasm x264 x265 fdkaac opus numactl + sudo pacman -S --noconfirm libvpx || true +} + +build_libva() { + echo "Building libva" + "$this_dir/build-libva" } compile_libaom() { @@ -141,6 +148,7 @@ dir=$(pwd) mkdir -p "$source_dir" "$bin_dir" install_dependencies +build_libva -s "$source_dir/libva" compile_libaom compile_libsvtav1 compile_libvmaf diff --git a/scripts/build-libva b/scripts/build-libva index e7b706a..5ece54e 100755 --- a/scripts/build-libva +++ b/scripts/build-libva @@ -1,7 +1,7 @@ #!/bin/env bash set -euo pipefail -usage="$(basename "$0") [-h] -- Compiles libva from source and +usage="$(basename "$0") [-h] -- Compiles libva from source and installs it to . The libraries will be installed to /lib. If the prefix is not provided, the script will exit. @@ -10,10 +10,10 @@ The packages managers \`apt\` and \`pacman\` are supported. where: -h, --help show this help text -s, --source-dir source directory (default: ./libva) - the prefix to install libva to" + -p, --prefix the prefix to install libva to (default: /usr)" src="./libva" -prefix="" +prefix="/usr" while [[ $# -gt 0 ]]; do key="$1" case $key in @@ -43,11 +43,14 @@ src=$(realpath "$src") prefix=$(realpath "$prefix") install_deps() { + echo "Installing dependencies" if command -v apt-get &>/dev/null; then echo "apt-get found" + remove_libva_apt install_deps_apt elif command -v pacman &>/dev/null; then echo "pacman found" + remove_libva_pacman install_deps_pacman else echo "No supported package manager found" @@ -55,17 +58,32 @@ install_deps() { fi } +remove_libva_apt() { + echo "Removing libva" + sudo apt-get -y remove libva-dev || true + sudo apt-get -y remove libva2 || true +} + +remove_libva_pacman() { + echo "Removing libva" + sudo pacman -R --noconfirm -dd libva || true +} + install_deps_apt() { - sudo apt-get -y install git cmake pkg-config meson libdrm-dev automake libtool autogen + echo "Installing apt dependencies" + sudo apt-get -y install autogen automake cmake git libdrm-dev libtool libwayland-dev libx11-dev libx11-dev libx11-xcb-perl libx11-xcb1 libxcb-dri3-dev libxcb1-dev libxext-dev libxfixes-dev meson pkg-config xorg-dev } install_deps_pacman() { - sudo pacman -S --noconfirm git cmake pkg-config meson libdrm automake libtool autogen + echo "Installing pacman dependencies" + sudo pacman -S --noconfirm git cmake pkg-config meson libdrm automake libtool autogen xorg wayland libxext libxfixes } build_libva() { dir=$(pwd) + rm -rf "$src" cd "$(dirname "$src")" + echo "Cloning libva" git clone https://github.com/intel/libva.git -o "$(basename "$src")" cd "$(basename "$src")" ./autogen.sh --prefix="$prefix" --libdir="$prefix/lib" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4485ed..93e51f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,13 +27,9 @@ set(LINK_LIBS spdlog::spdlog_header_only Boost::boost Boost::filesystem Qt6::Widgets Qt6::Multimedia Qt6::MultimediaWidgets) # When building the project with a static Qt6 library, we need to link the -# following components statically as well: -# - Platform plugins -# - Multimedia plugins -# - FFmpeg -# - Libva -# Furthermore, the Qt plugins need to be imported manually using the -# qt_import_plugins() function. +# following components statically as well: - Platform plugins - Multimedia +# plugins - FFmpeg - Libva Furthermore, the Qt plugins need to be imported +# manually using the qt_import_plugins() function. if(QT6_LIB_TYPE STREQUAL "STATIC_LIBRARY") set(PLATFORM_PLUGINS Qt6::QEglFSIntegrationPlugin @@ -52,10 +48,19 @@ if(QT6_LIB_TYPE STREQUAL "STATIC_LIBRARY") find_libva() # creates Libva::va/va-drm/va-x11/va-wayland message(STATUS "FFmpeg libraries are: ${FFMPEG_LIBRARIES}") + get_target_property(VA_LIBRARY Libva::va LOCATION) + get_target_property(VA_DRM_LIBRARY Libva::va-drm LOCATION) + get_target_property(VA_X11_LIBRARY Libva::va-x11 LOCATION) + get_target_property(VA_WAYLAND_LIBRARY Libva::va-wayland LOCATION) + + message(STATUS "Libva::va library is: ${VA_LIBRARY}") + message(STATUS "Libva::va-drm library is: ${VA_DRM_LIBRARY}") + message(STATUS "Libva::va-x11 library is: ${VA_X11_LIBRARY}") + message(STATUS "Libva::va-wayland library is: ${VA_WAYLAND_LIBRARY}") + list( APPEND LINK_LIBS - FFmpeg::FFmpeg Libva::va Libva::va-drm Libva::va-x11