Skip to content

Commit

Permalink
compile mesa, add vulkan deps, remove var
Browse files Browse the repository at this point in the history
  • Loading branch information
aptalca committed Nov 25, 2023
1 parent 3b529cd commit f153b39
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 16 deletions.
62 changes: 58 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ENV \
LIBVIDSTAB=1.1.1 \
LIBVMAF=2.3.1 \
LIBVPL=2023.3.1 \
MESA=23.2.1 \
NVCODEC=n12.1.14.0 \
OGG=1.3.5 \
ONEVPL=23.3.4 \
Expand Down Expand Up @@ -78,6 +79,7 @@ RUN \
libxext-dev \
libxfixes-dev \
libxml2-dev \
libxrandr-dev \
make \
nasm \
ninja-build \
Expand All @@ -91,12 +93,13 @@ RUN \
xxd \
yasm \
zlib1g-dev && \
apt-get build-dep mesa -y && \
python3 -m venv /lsiopy && \
pip install -U --no-cache-dir \
pip \
setuptools \
wheel && \
pip install --no-cache-dir meson cmake
pip install --no-cache-dir meson cmake mako

# compile 3rd party libs
RUN \
Expand Down Expand Up @@ -277,6 +280,22 @@ RUN \
/usr/local/lib/libva-glx.so \
/usr/local/lib/libva-wayland.so \
/usr/local/lib/libva-x11.so
RUN \
echo "**** grabbing mesa ****" && \
mkdir -p /tmp/mesa && \
curl -Lf \
https://archive.mesa3d.org/mesa-${MESA}.tar.xz | \
tar -xJ --strip-components=1 -C /tmp/mesa
RUN \
echo "**** compiling mesa ****" && \
cd /tmp/mesa && \
meson setup \
-Dprefix="/usr/local" \
-Dbuildtype=release \
-Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec \
builddir/ && \
meson compile -C builddir/ && \
meson install -C builddir/
RUN \
echo "**** grabbing gmmlib ****" && \
mkdir -p /tmp/gmmlib && \
Expand Down Expand Up @@ -304,11 +323,11 @@ RUN \
mkdir -p /tmp/ihd/build && \
cd /tmp/ihd/build && \
cmake \
-DLIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri/ \
-DLIBVA_DRIVERS_PATH=/usr/local/lib/x86_64-linux-gnu/dri/ \
.. && \
make && \
make install && \
strip -d /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
strip -d /usr/local/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
RUN \
echo "**** grabbing libvpl ****" && \
mkdir -p /tmp/libvpl && \
Expand Down Expand Up @@ -572,6 +591,25 @@ RUN \
cd /tmp/vulkan-headers && \
cmake -S . -B build/ && \
cmake --install build --prefix /usr/local
RUN \
echo "**** grabbing vulkan loader ****" && \
mkdir -p /tmp/vulkan-loader && \
git clone \
--branch ${VULKANSDK} \
--depth 1 https://github.com/KhronosGroup/Vulkan-Loader.git \
/tmp/vulkan-loader
RUN \
echo "**** compiling vulkan loader ****" && \
cd /tmp/vulkan-loader && \
mkdir -p build && \
cd build && \
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D VULKAN_HEADERS_INSTALL_DIR=/usr/local/lib/x86_64-linux-gnu \
-D CMAKE_INSTALL_PREFIX=/usr/local \
.. && \
make && \
make install
RUN \
echo "**** grabbing webp ****" && \
mkdir -p /tmp/webp && \
Expand Down Expand Up @@ -693,6 +731,7 @@ RUN \
/buildout/usr/local/lib/mfx \
/buildout/usr/local/lib/vpl \
/buildout/usr/local/lib/x86_64-linux-gnu/dri \
/buildout/usr/local/share/vulkan \
/buildout/etc/OpenCL/vendors && \
cp \
/tmp/ffmpeg/ffmpeg \
Expand All @@ -716,8 +755,14 @@ RUN \
/usr/local/lib/x86_64-linux-gnu/lib*so* \
/buildout/usr/local/lib/x86_64-linux-gnu/ && \
cp -a \
/usr/lib/x86_64-linux-gnu/dri/*.so \
/usr/local/lib/x86_64-linux-gnu/dri/*.so \
/buildout/usr/local/lib/x86_64-linux-gnu/dri/ && \
cp -a \
/usr/lib/x86_64-linux-gnu/dri/i965* \
/buildout/usr/local/lib/x86_64-linux-gnu/dri/ && \
cp -a \
/usr/local/share/vulkan/* \
/buildout/usr/local/share/vulkan/ && \
echo \
'libnvidia-opencl.so.1' > \
/buildout/etc/OpenCL/vendors/nvidia.icd
Expand Down Expand Up @@ -747,21 +792,30 @@ RUN \
echo "**** install runtime ****" && \
apt-get update && \
apt-get install -y \
libedit2 \
libelf1 \
libexpat1 \
libglib2.0-0 \
libgomp1 \
libharfbuzz0b \
libllvm15 \
libmpdec3 \
libpciaccess0 \
libv4l-0 \
libwayland-client0 \
libx11-6 \
libx11-xcb1 \
libxcb-dri3-0 \
libxcb-present0 \
libxcb-randr0 \
libxcb-shape0 \
libxcb-shm0 \
libxcb-sync1 \
libxcb-xfixes0 \
libxcb1 \
libxext6 \
libxfixes3 \
libxshmfence1 \
libxml2 \
ocl-icd-libopencl1 && \
echo "**** clean up ****" && \
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,20 @@ docker run --rm -it \

### Vulkan support

Preliminary Vulkan support has been added to x86_64, which can be enabled by setting the environment variable `ENABLE_VULKAN=true`. When enabled, the container will download and install the Vulkan loader and dependencies from the Ubuntu repo prior to running FFmpeg on container start.
Vulkan support has been added to x86_64 (tested with Intel iGPU) ([click for more info](https://trac.ffmpeg.org/wiki/HWAccelIntro#Vulkan)).

Some Vulkan extensions may not yet be available due to installing an older version of MESA and Vulkan loader from the Ubuntu repository.
```
docker run --rm -it \
--device=/dev/dri:/dev/dri \
-v $(pwd):/config \
-e ANV_VIDEO_DECODE=1 \
linuxserver/ffmpeg \
-init_hw_device "vulkan=vk:0" \
-hwaccel vulkan \
-hwaccel_output_format vulkan \
-i /config/input.mkv \
-f null - -benchmark
```

## Building locally

Expand All @@ -157,6 +168,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **25.11.23:** - Compile Mesa from source. Add proper Vulkan support (env var `ENABLE_VULKAN=true` no longer needed)(tested with Intel).
* **22.11.23:** - Add shaderc and (preliminary) Vulkan support (via env var `ENABLE_VULKAN=true`) to x86_64. Bump Intel drivers and other libs.
* **13.11.23:** - Bump FFmpeg to 6.1.
* **02.11.23:** - Remove `--enable-small` from ffmpeg build options to add back some features.
Expand Down
16 changes: 14 additions & 2 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,20 @@ full_custom_readme: |
### Vulkan support
Preliminary Vulkan support has been added to x86_64, which can be enabled by setting the environment variable `ENABLE_VULKAN=true`. When enabled, the container will download and install the Vulkan loader and dependencies from the Ubuntu repo prior to running FFmpeg on container start.
Vulkan support has been added to x86_64 (tested with Intel iGPU) ([click for more info](https://trac.ffmpeg.org/wiki/HWAccelIntro#Vulkan)).
Some Vulkan extensions may not yet be available due to installing an older version of MESA and Vulkan loader from the Ubuntu repository.
```
docker run --rm -it \
--device=/dev/dri:/dev/dri \
-v $(pwd):/config \
-e ANV_VIDEO_DECODE=1 \
linuxserver/ffmpeg \
-init_hw_device "vulkan=vk:0" \
-hwaccel vulkan \
-hwaccel_output_format vulkan \
-i /config/input.mkv \
-f null - -benchmark
```
## Building locally
Expand All @@ -161,6 +172,7 @@ full_custom_readme: |
## Versions
* **25.11.23:** - Compile Mesa from source. Add proper Vulkan support (env var `ENABLE_VULKAN=true` no longer needed)(tested with Intel).
* **22.11.23:** - Add shaderc and (preliminary) Vulkan support (via env var `ENABLE_VULKAN=true`) to x86_64. Bump Intel drivers and other libs.
* **13.11.23:** - Bump FFmpeg to 6.1.
* **02.11.23:** - Remove `--enable-small` from ffmpeg build options to add back some features.
Expand Down
8 changes: 0 additions & 8 deletions root/ffmpegwrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,4 @@ do
fi
done

## vulkan support ##
if [[ "${ENABLE_VULKAN}" = "true" ]]; then
echo "**** Installing Vulkan dependencies ****"
apt-get update
apt-get install -y libvulkan1
echo "**** Vulkan dependencies installed ****"
fi

run_ffmpeg

0 comments on commit f153b39

Please sign in to comment.