From 2e909accce50495aa195f93580c9dede99ad7db4 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:10:21 -0400 Subject: [PATCH 1/2] add latest iHD and libvpl/msdk for qsv --- Dockerfile | 91 ++++++++++++++++++++++++++++++++++++++++++++-- Dockerfile.aarch64 | 8 +++- README.md | 1 + readme-vars.yml | 1 + 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3028f6a..ac23d1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,12 +25,15 @@ ENV \ LAME=3.100 \ LIBASS=0.17.1 \ LIBDRM=2.4.115 \ + LIBMFX=22.5.4 \ LIBVA=2.18.0 \ LIBVDPAU=1.5 \ LIBVIDSTAB=1.1.1 \ LIBVMAF=2.3.1 \ + LIBVPL=2023.3.0 \ NVCODEC=n12.0.16.0 \ OGG=1.3.5 \ + ONEVPL=23.1.5 \ OPENCOREAMR=0.1.6 \ OPENJPEG=2.5.0 \ OPUS=1.3.1 \ @@ -56,6 +59,7 @@ RUN \ gperf \ libexpat1-dev \ libxext-dev \ + libxfixes-dev \ libgcc-10-dev \ libgomp1 \ libharfbuzz-dev \ @@ -63,7 +67,11 @@ RUN \ libssl-dev \ libtool \ libv4l-dev \ + libwayland-dev \ libx11-dev \ + libx11-xcb-dev \ + libxcb-dri3-dev \ + libxcb-present-dev \ libxml2-dev \ make \ nasm \ @@ -72,6 +80,7 @@ RUN \ perl \ pkg-config \ python3-venv \ + wayland-protocols \ x11proto-xext-dev \ xserver-xorg-dev \ xxd \ @@ -82,7 +91,7 @@ RUN \ pip \ setuptools \ wheel && \ - pip install --no-cache-dir meson + pip install --no-cache-dir meson cmake # compile 3rd party libs RUN \ @@ -257,8 +266,12 @@ RUN \ --enable-shared && \ make && \ make install && \ - strip -d /usr/local/lib/libva.so && \ - strip -d /usr/local/lib/libva-drm.so + strip -d \ + /usr/local/lib/libva.so \ + /usr/local/lib/libva-drm.so \ + /usr/local/lib/libva-glx.so \ + /usr/local/lib/libva-wayland.so \ + /usr/local/lib/libva-x11.so RUN \ echo "**** grabbing gmmlib ****" && \ mkdir -p /tmp/gmmlib && \ @@ -291,6 +304,60 @@ RUN \ make && \ make install && \ strip -d /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so +RUN \ + echo "**** grabbing libvpl ****" && \ + mkdir -p /tmp/libvpl && \ + curl -Lf \ + https://github.com/oneapi-src/oneVPL/archive/refs/tags/v${LIBVPL}.tar.gz | \ + tar -zx --strip-components=1 -C /tmp/libvpl +RUN \ + echo "**** compiling libvpl ****" && \ + mkdir -p /tmp/libvpl/build && \ + cd /tmp/libvpl/build && \ + cmake .. && \ + cmake --build . --config Release && \ + cmake --build . --config Release --target install && \ + strip -d /usr/local/lib/libvpl.so +RUN \ + echo "**** grabbing onevpl ****" && \ + mkdir -p /tmp/onevpl && \ + curl -Lf \ + https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${ONEVPL}.tar.gz | \ + tar -zx --strip-components=1 -C /tmp/onevpl +RUN \ + echo "**** compiling onevpl ****" && \ + mkdir -p /tmp/onevpl/build && \ + cd /tmp/onevpl/build && \ + cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_INSTALL_LIBDIR=/usr/local/lib \ + .. && \ + make && \ + make install && \ + strip -d /usr/local/lib/libmfx-gen.so +RUN \ + echo "**** grabbing libmfx ****" && \ + mkdir -p /tmp/libmfx && \ + curl -Lf \ + https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${LIBMFX}.tar.gz | \ + tar -zx --strip-components=1 -C /tmp/libmfx +RUN \ + echo "**** compiling libmfx ****" && \ + mkdir -p /tmp/libmfx/build && \ + cd /tmp/libmfx/build && \ + cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_INSTALL_LIBDIR=/usr/local/lib \ + -DBUILD_SAMPLES=OFF \ + -DENABLE_X11_DRI3=ON \ + -DBUILD_DISPATCHER=OFF \ + -DBUILD_TUTORIALS=OFF \ + .. && \ + make && \ + make install && \ + strip -d \ + /usr/local/lib/libmfxhw64.so \ + /usr/local/lib/mfx/libmfx_*.so RUN \ echo "**** grabbing libvdpau ****" && \ mkdir -p /tmp/libvdpau && \ @@ -537,6 +604,7 @@ RUN \ --enable-libvidstab \ --enable-libvmaf \ --enable-libvorbis \ + --enable-libvpl \ --enable-libvpx \ --enable-libxml2 \ --enable-libx264 \ @@ -559,6 +627,9 @@ RUN \ ldconfig && \ mkdir -p \ /buildout/usr/local/bin \ + /buildout/usr/local/lib/libmfx-gen \ + /buildout/usr/local/lib/mfx \ + /buildout/usr/local/lib/vpl \ /buildout/usr/local/lib/x86_64-linux-gnu/dri \ /buildout/etc/OpenCL/vendors && \ cp \ @@ -570,6 +641,15 @@ RUN \ cp -a \ /usr/local/lib/lib*so* \ /buildout/usr/local/lib/ && \ + cp -a \ + /usr/local/lib/libmfx-gen/*.so \ + /buildout/usr/local/lib/libmfx-gen/ && \ + cp -a \ + /usr/local/lib/mfx/*.so \ + /buildout/usr/local/lib/mfx/ && \ + cp -a \ + /usr/local/lib/vpl/*.so \ + /buildout/usr/local/lib/vpl/ && \ cp -a \ /usr/local/lib/x86_64-linux-gnu/lib*so* \ /buildout/usr/local/lib/x86_64-linux-gnu/ && \ @@ -597,6 +677,7 @@ ARG DEBIAN_FRONTEND="noninteractive" # hardware env ENV \ LIBVA_DRIVERS_PATH="/usr/local/lib/x86_64-linux-gnu/dri" \ + LD_LIBRARY_PATH="/usr/local/lib" \ NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" \ NVIDIA_VISIBLE_DEVICES="all" @@ -609,11 +690,15 @@ RUN \ libgomp1 \ libharfbuzz0b \ libv4l-0 \ + libwayland-client0 \ libx11-6 \ + libx11-xcb1 \ libxcb1 \ + libxcb-dri3-0 \ libxcb-shape0 \ libxcb-xfixes0 \ libxext6 \ + libxfixes3 \ libxml2 \ ocl-icd-libopencl1 && \ echo "**** clean up ****" && \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index b7dc0cd..131ab11 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -71,7 +71,13 @@ RUN \ xserver-xorg-dev \ xxd \ yasm \ - zlib1g-dev + zlib1g-dev && \ + python3 -m venv /lsiopy && \ + pip install -U --no-cache-dir \ + pip \ + setuptools \ + wheel && \ + pip install --no-cache-dir cmake # compile 3rd party libs RUN \ diff --git a/README.md b/README.md index 1bdbc48..21a06ea 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **14.06.23:** - Switch to latest iHD for Intel, add qsv support. * **13.06.23:** - Bump to 6.0, update shared libraries, deprecate armhf, combine bin stage. * **14.12.22:** - Rebase to Jammy, bump to 5.1.2. * **19.06.22:** - Rebase to Focal. diff --git a/readme-vars.yml b/readme-vars.yml index b8f406c..2440472 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -131,6 +131,7 @@ full_custom_readme: | ## Versions + * **14.06.23:** - Switch to latest iHD for Intel, add qsv support. * **13.06.23:** - Bump to 6.0, update shared libraries, deprecate armhf, combine bin stage. * **14.12.22:** - Rebase to Jammy, bump to 5.1.2. * **19.06.22:** - Rebase to Focal. From 8e22a434feb8dc9306a65be621a63a05a05f0d97 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Wed, 14 Jun 2023 19:06:56 -0400 Subject: [PATCH 2/2] update readme --- README.md | 29 ++++++++++++++++++++++++++--- readme-vars.yml | 31 +++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 21a06ea..b70ac40 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,17 @@ The architectures supported by this image are: Unlike most of our container library this image is meant to be run ephemerally from the command line parsing user input for a custom FFmpeg command. You will need to understand some Docker basics to use this image and be familiar with how to construct an FFmpeg command. In the commands below we will be bind mounting our current working directory from the CLI to /config, the assumption is that input.mkv is in your current working directory. -If an input file is detected we will run FFmpeg as that user/group so the output file will match it's permissions. +If an input file is detected we will run FFmpeg as that user/group so the output file will match its permissions. The image supports Hardware acceleration on x86 pay close attention to the variables for the examples below. +### Included Intel Drivers (latest versions compiled): +- iHD Driver: Supports gen8+ +- Libva (VAAPI): Supports gen5+ but is limited to gen8+ due to iHD driver +- Qsv Dispatcher: OneVPL (supports both OneVPL and MSDK runtimes and should automatically switch) +- Qsv Runtime: + - OneVPL: Supports gen12+ + - MSDK (libmfx): Supports gen8 - gen12 + ### Basic Transcode ``` @@ -75,7 +83,7 @@ docker run --rm -it \ /config/output.mkv ``` -### Hardware accelerated (VAAPI) +### Hardware accelerated (VAAPI) ([click for more info](https://trac.ffmpeg.org/wiki/Hardware/VAAPI)) ``` docker run --rm -it \ @@ -91,7 +99,22 @@ docker run --rm -it \ /config/output.mkv ``` -### Nvidia Hardware accelerated +### Hardware accelerated (QSV) ([click for more info](https://trac.ffmpeg.org/wiki/Hardware/QuickSync)) + +``` +docker run --rm -it \ + --device=/dev/dri:/dev/dri \ + -v $(pwd):/config \ + linuxserver/ffmpeg \ + -hwaccel qsv \ + -c:v h264_qsv \ + -i /config/input.mkv \ + -c:v h264_qsv \ + -global_quality 25 \ + /config/output.mkv +``` + +### Nvidia Hardware accelerated ([click for more info](https://trac.ffmpeg.org/wiki/HWAccelIntro#CUDANVENCNVDEC)) ``` docker run --rm -it \ diff --git a/readme-vars.yml b/readme-vars.yml index 2440472..8e848f6 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -61,9 +61,17 @@ full_custom_readme: | Unlike most of our container library this image is meant to be run ephemerally from the command line parsing user input for a custom FFmpeg command. You will need to understand some Docker basics to use this image and be familiar with how to construct an FFmpeg command. In the commands below we will be bind mounting our current working directory from the CLI to /config, the assumption is that input.mkv is in your current working directory. - If an input file is detected we will run FFmpeg as that user/group so the output file will match it's permissions. + If an input file is detected we will run FFmpeg as that user/group so the output file will match its permissions. The image supports Hardware acceleration on x86 pay close attention to the variables for the examples below. - + + ### Included Intel Drivers (latest versions compiled): + - iHD Driver: Supports gen8+ + - Libva (VAAPI): Supports gen5+ but is limited to gen8+ due to iHD driver + - Qsv Dispatcher: OneVPL (supports both OneVPL and MSDK runtimes and should automatically switch) + - Qsv Runtime: + - OneVPL: Supports gen12+ + - MSDK (libmfx): Supports gen8 - gen12 + ### Basic Transcode ``` @@ -78,7 +86,7 @@ full_custom_readme: | /config/output.mkv ``` - ### Hardware accelerated (VAAPI) + ### Hardware accelerated (VAAPI) ([click for more info](https://trac.ffmpeg.org/wiki/Hardware/VAAPI)) ``` docker run --rm -it \ @@ -94,7 +102,22 @@ full_custom_readme: | /config/output.mkv ``` - ### Nvidia Hardware accelerated + ### Hardware accelerated (QSV) ([click for more info](https://trac.ffmpeg.org/wiki/Hardware/QuickSync)) + + ``` + docker run --rm -it \ + --device=/dev/dri:/dev/dri \ + -v $(pwd):/config \ + linuxserver/ffmpeg \ + -hwaccel qsv \ + -c:v h264_qsv \ + -i /config/input.mkv \ + -c:v h264_qsv \ + -global_quality 25 \ + /config/output.mkv + ``` + + ### Nvidia Hardware accelerated ([click for more info](https://trac.ffmpeg.org/wiki/HWAccelIntro#CUDANVENCNVDEC)) ``` docker run --rm -it \