Hardware transcoding not working due to incorrect permissions
ovicus opened this issue · comments
Expected Behavior
On a device with Intel QuickSync, when /dev/dri
is correctly mapped, Plex should use /dev/dri/renderD128
for hardware transcoding.
Current Behavior
Hardware transcoding not working due to permissions issue.
docker-compose.yml
version: "2.1"
services:
plex:
container_name: plex
image: cr.hotio.dev/hotio/plex
devices:
- /dev/dri:/dev/dri
environment:
- PUID=1000
- PGID=1000
- UMASK=002
- TZ=Europe/London
- PLEX_CLAIM=claim-REDACTED
- PLEX_PASS=yes
volumes:
- /appdata/plex/config:/config
- /appdata/plex/transcode:/transcode
- /data/media:/media
ports:
- 32400:32400
restart: unless-stopped
$ docker exec -it plex bash
$ ls -la /dev/dri
total 0
drwxr-xr-x 2 root root 80 Nov 5 19:26 .
drwxr-xr-x 6 root root 360 Nov 5 19:26 ..
crw-rw---- 1 nobody video 226, 0 Nov 5 19:24 card0
crw-rw---- 1 nobody 108 226, 128 Oct 31 16:13 renderD128
$ id hotio
uid=1000(hotio) gid=1000(hotio) groups=1000(hotio),100(users)
- Device
/dev/dri/renderD128
should be owned by grouprender
that doesn't exist. - User
hotio
should be member ofrender
group.
As a result, Plex fails to use /dev/dri/renderD128
to do hardware trancoding, with following message in the logs
DEBUG - [Req#14f/Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Generic error in an external library
DEBUG - [Req#14f/Transcode] Could not create hardware context for hevc
Steps to Reproduce
See above
Workaround
$ docker exec -it plex bash
$ groupadd -g 108 render
$ usermod -aG render hotio
$ exit
$ docker restart plex
These changes don't survive a system restart. When container is destroyed, these changes are lost.
Environment
Ubuntu 22.04.1 LTS (GNU/Linux 5.15.64-1-pve x86_64)
After further investigation, I found the command
find /dev/dri /dev/dvb -type c -print 2>/dev/null
returns nothing when run within the container. Because of that, the script https://github.com/hotio/plex/blob/release/root/etc/cont-init.d/04-hw-support fails to create the missing group for the relevant devices.
When removing -type c
from the command above, it returns the relevant devices + parent directory
$ find /dev/dri /dev/dvb -type c -print 2>/dev/null
<nothing printed>
$ find /dev/dri /dev/dvb -print 2>/dev/null
/dev/dri
/dev/dri/renderD128
/dev/dri/card0
but when called with -type f
, it displays the expected output
$ find /dev/dri /dev/dvb -type f -print 2>/dev/null
/dev/dri/renderD128
/dev/dri/card0
Can't reproduce on my system
Very strange. I just created a fresh new host (LXC) with Ubuntu 18.04 (in case it was an issue with recent Ubuntu version) and could reproduce, using the same docker-compose.yml
I posted before.
root@hotioplex:/docker# docker exec -it plex bash
root@6adb555c49dc:/# ls -la /dev/dri
total 0
drwxr-xr-x 2 root root 80 Nov 6 19:53 .
drwxr-xr-x 6 root root 360 Nov 6 19:53 ..
crw-rw---- 1 nobody video 226, 0 Nov 6 09:48 card0
crw-rw---- 1 nobody 108 226, 128 Oct 31 16:13 renderD128
root@6adb555c49dc:/# find /dev/dri /dev/dvb -type c -print 2>/dev/null
root@6adb555c49dc:/# find /dev/dri /dev/dvb -type f -print 2>/dev/null
/dev/dri/renderD128
/dev/dri/card0