Got HW Transcoding to work with libva/vaapi on Ryzen APU (Ryzen 7 4700U)

I just pushed the most recent 1.25.5.5492
to Docker Hub

The container doesn’t update itself while running, in-line with Docker best practices the image itself gets updated with the latest update whenever I push to the repository. ie. you might have to pull the new image to your docker (or use a solution like watchtower to do this automatically)

2 Likes

Hey. Thank you very much. One question: Is there a way to do it manually? I currently have plex installed on my ubuntu machine.

Excellent thread with tons of great information - thank you.

I very quickly had this (apparently) functioning normally on Unraid. Lower CPU utilization, (hw) clearly output on the dashboard.

However, I quickly discovered that it creates the initial ~60 seconds buffer, it won’t continue transcoding. My stream dies and I get the spinning wheel and it doesn’t recover.

Any thoughts on why this might be the case? Looking at the plex console doesn’t reveal any obvious error message. It’s as if the transcode sleeps and just doesn’t wake back up as the buffer expires.

First of thank you for your work, I read through all of this thread would a regular gpu work with this container? I do have a 5600g apu but I have a 5500xt just sitting on my shelf.

@mauimauer have you ever thought of making a “mod” for the official linuxserver one?
https://www.linuxserver.io/blog/2019-09-14-customizing-our-containers
would be way cool :slight_smile:

2 Likes

yes, in the thread you see a most using "regular gpu"s, it does work with APUs as well though.
unfortunately with the current amdgpupro 20.50.2 i get constant color flickering

Any advice for implementing on UNRAID for a complete noob? I see some people have installed with success, but the install directions seem to point to a different directory than I recognize. Does any one have a blow by blow instructions?
Trying to get an HP t740 with Radeon Raven to work. Would like to modify the existing standard Plex docker install.

For example, first command is:
cp /lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so /usr/lib/plexmediaserver/lib/dri/ && \

I don’t see a directory for:
/usr/lib/plexmediaserver/

1 Like

Is anyone noticing poor encoder quality and random green/red flashes?

yes… thats why i disabled hw transcoding :frowning:
if you figure it out, itd be nice to know ^^

In unraid docker webUI, use the default plex docker app then change “Repository” to mauimauer/spritsail-plex
Follow the rest of the instructions in this thread for variables, paths, etc. (/dev/dri, plex claim code, etc)

The latest version should be up on DockerHub. It seems we have a new issue (as reported here in the thread alread), which is green/pink or red frames flashing while transcoding on the HW is underway. I am uncertain wether this is due to Plex’s Transcoder or a problem with the AMDGPU Mesa drivers.

Meybe it’s worth reporting this to the Plex developers (even if AMD isn’t officially supported. VAAPI is)

1 Like

Thank you for this awesome Guide !
This helped me a lot and know my AMD Ryzen 7 5700G is transcoding all with Hardware and not software only.

2 Likes

With inspiration from @mauimauer and the spritsail image- there’s really nothing stopping this from running on top of the native pms or linuxservers ubuntu based image. Here’s the proof:

ARG OUTPUT=/output

FROM alpine:edge AS builder

RUN apk add --no-cache \
        autoconf \
        automake \
        binutils \
        cmake \
        curl \
        dpkg \
        file \
        gcc \
        g++ \
        libc6-compat \
        git \
        libtool \
        linux-headers \
        make \
        musl-dev \
        nghttp2-dev \
        pkgconfig \
        xxd

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


FROM builder AS amd

ARG CFLAGS
ARG LDFLAGS
ARG MAKEFLAGS
ARG OUTPUT
ARG DESTDIR

WORKDIR /tmp/amd

RUN apk add  xf86-video-amdgpu linux-firmware-amdgpu --no-cache --update-cache \
 && apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing libva-utils \
 && mkdir -p "$OUTPUT/usr/bin" \
 && cp -a /usr/bin/vainfo "$OUTPUT/usr/bin" \
 && mkdir -p "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libX*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libwayland*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libva*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libdrm*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libbsd*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libxshmfence*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libkms*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libxcb*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libffi*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libLLVM*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libzstd*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libexpat*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libelf*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libstdc++*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libgcc_s*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libmd*.so* "$OUTPUT/usr/lib" \
 && cp -a /usr/lib/libxml2*.so* "$OUTPUT/usr/lib" \
 && mkdir -p "$OUTPUT/usr/lib/dri" \
 && cp -a /usr/lib/dri/*.so* "$OUTPUT/usr/lib/dri" \
 && mkdir -p "$OUTPUT/usr/share/libdrm" \
 && cp -a /usr/share/libdrm/* "$OUTPUT/usr/share/libdrm" \
 && cp -a /lib/ld-musl-x86_64.so.1 "$OUTPUT/usr/lib" \
 && cp -a /lib/libz*.so* "$OUTPUT/usr/lib"



FROM plexinc/pms-docker

ARG OUTPUT

#Install AMD Specific
RUN apt-get update && \
 apt-get install -y software-properties-common && \
 add-apt-repository ppa:oibaf/graphics-drivers -y && \
 apt-get update && \
 apt-get upgrade -y && \
 apt-get install -y \
        vainfo \
        beignet-opencl-icd \
        mesa-va-drivers \
        mesa-vdpau-drivers \
        libdrm-amdgpu1 \
        radeontop \
        libavutil56 && \
 apt-get clean

#Manually move over the musl compiled modules
COPY --from=amd $OUTPUT/usr/lib/dri/*.so* /usr/lib/plexmediaserver/lib/dri/
COPY --from=amd $OUTPUT/usr/lib/libdrm*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libva*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libLLVM*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libffi*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libkms*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libzstd*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libelf*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libstdc++*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libgcc_s*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libxml2*.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/ld-musl-x86_64.so* /usr/lib/plexmediaserver/lib/
COPY --from=amd $OUTPUT/usr/lib/libz*.so.* /usr/lib/plexmediaserver/lib/

Build that container up and it should work relatively well. Passing through /dev/dri on an AMD Ryzen 5 3550H APU. That said, the image built from this is much larger than the spritsail/plex-media-server based image. YMMV, but figured I’d share.

For what it’s worth, it also has the occasional transcode artifacting (but it’s not constant). HDR tone mapping transcodes definitely offloads to the CPU though.

# vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.6.0)
vainfo: Driver version: Mesa Gallium driver 22.2.0-devel for AMD Radeon Vega 8 Graphics (raven, LLVM 14.0.0, DRM 3.40, 5.10.0-13-amd64)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

image

1 Like

I think we all assumed it would work just fine, but I would be very interested in someone turning this into a plugin for the linuxserver/official images (which I think are based on the linuxserver ones?) using this as a guide Customizing our Containers | LinuxServer.io

I believe that would make it so we can use the normal regularly updated images for this.

2 Likes

Excellent stuff. I am still curious to find the cause of the transcoder artifacts (red, green and purple flashes). It was definitely not present when I first put together a HW enabled container for AMD. Question is if it’s a regression with the AMD Mesa drivers or something caused by the Plex Transcoder

Keep us posted as also been experiencing this for a few weeks and had to turn HW transcoding off.

that would indeed be the coolest solution for many :smiley:
i guess if the artifacts wouldnt be there, a solution like @syst.m suggested to create a linuxserver mod would be worth to try

Hey I tried to switch from the linuxserver/plex image to yours but it simply will not grant me access to my library?
I did enter a new Claim token but it will not work…
I really do not want to redo my whole Library but it would be so great if my new APU would be able to HW transcode.
What do I have to do so I can switch to this image?

Here is my current compose setup:

version: "3.4"

networks:
  traefik:
    external: 
     name: traefik
  plex:
    driver: bridge

services:
  plex:
    image: linuxserver/plex:latest
    container_name: plex
    restart: always
    devices:
      - /dev/dri:/dev/dri
    environment:
      - PUID=99
      - PGID=100
      - UMASK=002
      - VERSION=docker
      - TZ="Europe/Berlin"
      - PLEX_CLAIM="*********************"
    volumes:
      # Directory for Config files
      - type: bind
        source: /mnt/user/appdata/plex
        target: /config
      # Directory for Media Files
      - type: bind
        source: /mnt/user/Data/media
        target: /data
      # Directory for transcoding
      - type: bind
        source: /tmp
        target: /transcode
    networks:
       - traefik
       - plex
    ports:
      - 32400:32400

  tautulli:
    image: linuxserver/tautulli
    container_name: tautulli
    environment:
      - PUID=99
      - PGID=100
      - UMASK=002
      - TZ=Europe/Berlin
    volumes:
      # Directory for Config files
      - type: bind
        source: /mnt/user/appdata/tautulli
        target: /config
    networks:
      - traefik
    restart: always

Hi, @Teknowiz @cybrnook @darkalfie @V1P_J0K3R

Do you know how much simultaneous transcoding you can have with the 5700G ?

In 1080p & 4K

Thanks :slight_smile:

I am using 4650G with unraid 6.10, got same situation. Playing video in web