pdulvp / jellyfin-qnap

Jellyfin server packaging for QNAP NAS
https://jellyfin.org
505 stars 33 forks source link

hardware acceleration doesn't work on TVS-473e #92

Open Lohann opened 4 months ago

Lohann commented 4 months ago

I have an QNAP TVS-473e which does support hardware transcoding, but I'm unable to use it with jellyfin, I followed the Enable Video Acceleration in Jellyfin instructions but without success, then I ssh connected to my qnap to debug it:

#!/bin/sh
QPKG_ROOT=$(/sbin/getcfg jellyfin Install_Path -f /etc/config/qpkg.conf)

vainfo_check() {
  if [ "$1" != "" ]; then
    export LIBVA_DRIVER_NAME="$1"
    export LIBVA_DRIVER_NAME_JELLYFIN="$1"
  else
    unset LIBVA_DRIVER_NAME
    unset LIBVA_DRIVER_NAME_JELLYFIN
  fi

  # Check device
  result=$(
    "${QPKG_ROOT}/jellyfin/bin/ld-linux-x86-64.so.2" \
      --library-path "$QPKG_ROOT/jellyfin-ffmpeg/lib:${QPKG_ROOT}/jellyfin/bin" \
      "${QPKG_ROOT}/jellyfin-ffmpeg/vainfo2" \
      --all 2>&1
    )
    device_name="${LIBVA_DRIVER_NAME:-defaultValue}"
    printf "drive: %s\n%s\n\n" "${device_name}" "${result}"
}

vainfo_check
vainfo_check iHD
vainfo_check i965
Output [click here] ``` drive: defaultValue libva info: VA-API version 1.21.0 libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so libva error: dlopen of /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so failed: libxcb-sync.so.1: cannot open shared object file: No such file or directory libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so libva info: Trying to open /usr/local/lib/dri/radeonsi_drv_video.so libva info: va_openDriver() returns -1 vaInitialize failed with error code -1 (unknown libva error),exit Trying display: drm drive: iHD libva info: VA-API version 1.21.0 libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so libva error: dlopen of /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so failed: libxcb-sync.so.1: cannot open shared object file: No such file or directory libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so libva info: Trying to open /usr/local/lib/dri/radeonsi_drv_video.so libva info: va_openDriver() returns -1 vaInitialize failed with error code -1 (unknown libva error),exit Trying display: drm drive: i965 libva info: VA-API version 1.21.0 libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so libva error: dlopen of /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so failed: libxcb-sync.so.1: cannot open shared object file: No such file or directory libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so libva info: Trying to open /usr/local/lib/dri/radeonsi_drv_video.so libva info: va_openDriver() returns -1 vaInitialize failed with error code -1 (unknown libva error),exit Trying display: drm ```

Hardware transcoding works in other apps

If you have the Cayin Media Player installed, I checked that it is able to successfully use the ffmpeg for transcoding with VAAPI, but requires some dark magic:

#!/bin/sh
QPKG_ROOT=$(/sbin/getcfg MediaSignPlayer Install_Path -f /etc/config/qpkg.conf)
FFMPEG_CMD='ffmpeg -y -nostdin -vaapi_device "" -f lavfi -i testsrc=duration=0.01:size=1280x720:rate=30 -map 0:v:0? -vf format=nv12,hwupload -bf 0 -c:v h264_vaapi -low_power false -profile:v main -f null'

env -i /usr/sbin/chroot "$QPKG_ROOT/CodexPackExt" \
  "sh" "-c" \
  "LD_LIBRARY_PATH='/usr/lib/x86_64-linux-gnu:/opt/cdx/lib:/overlay_fs/merge/usr/lib:/overlay_fs/merge/cuda/lib64:' \
  PATH=/opt/cdx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
  FONTCONFIG_PATH=/etc/fonts: \
  LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri: \
  LIBVA_DRIVER_NAME=radeonsi \
  $FFMPEG_CMD"

output:

ffmpeg version 5.1.git Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/opt/codexpack/platform/x86_64/build/build --extra-cflags=-DQNAP --disable-doc --enable-gpl --enable-nonfree --enable-version3 --enable-shared --disable-static --enable-libaom --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-vaapi --enable-libvpl --disable-libx265 --disable-decoder=hevc --disable-hwaccel=hevc_vaapi --disable-encoder=hevc_vaapi --disable-decoder=hevc_cuvid --disable-decoder=hevc_v4l2m2m --disable-encoder=hevc_v4l2m2m --disable-encoder=hevc_nvenc --disable-encoder=hevc_qsv --disable-decoder=hevc_qsv --enable-cuda --enable-cuda-nvcc --enable-cuvid --enable-libnpp --enable-nvenc --disable-decoder=ac3 --disable-encoder=ac3 --disable-decoder=ac3_fixed --disable-encoder=ac3_fixed --disable-decoder=eac3 --disable-encoder=eac3 --disable-decoder=dca --disable-encoder=dca --disable-decoder=truehd --disable-encoder=truehd
  libavutil      58.  3.100 / 58.  3.100
  libavcodec     60.  6.100 / 60.  6.100
  libavformat    60.  4.100 / 60.  4.100
  libavdevice    60.  2.100 / 60.  2.100
  libavfilter     9.  4.100 /  9.  4.100
  libswscale      7.  2.100 /  7.  2.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
Trailing option(s) found in the command: may be ignored.
Input #0, lavfi, from 'testsrc=duration=0.01:size=1280x720:rate=30':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, rgb24, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 30 tbn
At least one output file must be specified