Files
shumai/scripts/docker-entrypoint.sh
T
Yiling-J 94ea4c917a feat(transcode): add VA-API hardware acceleration support (#430)
* feat(transcode): add VA-API hardware acceleration support

* fix(docker): switch to jellyfin-ffmpeg 8.1.2-5 for VA-API support

* fix(transcode): probe hardware encoder usability to skip uninitialized drivers

* ci(release): add workflow_dispatch trigger with custom tag input

* fix(transcode): use 256x256 frame dimension for encoder usability probe

* feat(docker): add hwaccel transcoding compose presets matching immich

* docs: add hardware transcoding documentation and quickstart references

* feat(transcode): prioritize h264_vaapi before h264_qsv on Linux

* fix(docker): extend device permission loop to rkmpp and wsl accelerator nodes
2026-09-26 20:55:57 +08:00

32 lines
1.0 KiB
Bash

#!/bin/sh
set -e
if [ "$(id -u)" = "0" ]; then
# Ensure the bun user has permissions to access mounted GPU and accelerator devices
# (/dev/dri/* for VA-API/QSV, /dev/rga, /dev/mpp_service, /dev/dma_heap/* for RKMPP, /dev/dxg for WSL2)
for dev in /dev/dri/* /dev/rga /dev/mpp_service /dev/dma_heap/* /dev/dxg; do
if [ -e "$dev" ]; then
gid=$(stat -c '%g' "$dev" 2>/dev/null || true)
if [ -n "$gid" ] && [ "$gid" != "0" ]; then
if ! getent group "$gid" >/dev/null 2>&1; then
groupadd -g "$gid" "hwaccel_group_$gid" 2>/dev/null || true
fi
usermod -a -G "$gid" bun 2>/dev/null || true
fi
fi
done
# Check if /app/data exists and is not owned by the bun user (UID 1000)
if [ -d "/app/data" ]; then
if [ "$(stat -c '%u' /app/data)" != "1000" ]; then
echo "Correcting permissions on /app/data..."
chown -R bun:bun /app/data
fi
fi
# Run the CMD as the bun user
exec gosu bun "$@"
else
# Run the CMD directly if already running as non-root
exec "$@"
fi