Please add mesa-va-drivers package in the docker image

Hi,
I want to use the plugin hardware-transcode-vaapi to support the hardware encoding. After installation the encoding failed because the package mesa-va-drivers is missing in the Docker image. Can you add please ?

FYI I added manualy this package in the container and it’s ok now, ffmpeg use the vaap device : /usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 …

1 « J'aime »

Even better, please support VAAPI hardware encoding natively without a plugin, including AV1 support.

1 « J'aime »

for those who need vaapi I have pushed a docker image here : https://hub.docker.com/r/fredix/peertube

The Dockerfile is really basic … :
FROM chocobozzz/peertube:production-bookworm
RUN apt update && apt install mesa-va-drivers -y

1 « J'aime »

Hi, any news ?

1 « J'aime »

hey fredix, i see we’re chasing the same thing between Owncast and Peertube.

i’ll be using your Peertube image here as well i guess.

no idea why this is such an issue for them.

i’m getting this error:

Error: ffmpeg exited with code 1: Device creation failed: -22.
Failed to set value ‹ /dev/dri/renderD128 › for option ‹ vaapi_device ›: Invalid argument
Error parsing global options: Invalid argument

any idea how to correct this? i do not think this argument is in use anymore.

I Nico198X, you have to install this extension in the admin interface :

BTW it seems that owncast works better than peertube to live streaming

1 « J'aime »

I don’t understand it’s a bit crazy… So you are welcome for using my image, tell me if you encounter an issue.

1 « J'aime »

thanks, yeah.

i think that plugin is broken now? it’s erroring out for me. it’s using an old argument that is no longer in use.

my github account isn’t functional right now, or i’d fork it and submit the fix. i think it just needs to change vaapi_device to hwaccel_device.

or vaapi may have new functionality to it that we may not need that at all:

vaapi

device is either an X11 display name, a DRM render node or a DirectX adapter index. If not specified, it will attempt to open the default X11 display ($DISPLAY) and then the first DRM render node (/dev/dri/renderD128), or the default DirectX adapter on Windows.

The following options are recognized:

kernel_driver

    When device is not specified, use this option to specify the name of the kernel driver associated with the desired device. This option is available only when the hardware acceleration method drm and vaapi are enabled. 
vendor_id

    When device and kernel_driver are not specified, use this option to specify the vendor id associated with the desired device. This option is available only when the hardware acceleration method drm and vaapi are enabled and kernel_driver is not specified. 

Examples:

-init_hw_device vaapi
    Create a vaapi device on the default device.

-init_hw_device vaapi:/dev/dri/renderD129
Create a vaapi device on DRM render node /dev/dri/renderD129.

-init_hw_device vaapi:1
    Create a vaapi device on DirectX adapter 1.

-init_hw_device vaapi:,kernel_driver=i915
Create a vaapi device on a device associated with kernel driver ‘i915’.

-init_hw_device vaapi:,vendor_id=0x8086
    Create a vaapi device on a device associated with vendor id ‘0x8086’.

I just try my image and it works. Are you sure that your GPU support vaapi ? Maybe I should add a driver in my image to support Intel hardware ? I switched to an AMD GPU which works better than Intel GPU (AMD Radeon 780M Graphics [Integrated]) and works on Linux out of the box.
Oh and does your Docker works on privilegied mode ? Peertube in Docker need an access to /dev/dri/renderD128 on the host.

/usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -i rtmp://127.0.0.1:1935/live/f7b19766-4071-41c6-8da5-0d1e61e71fe7 -y -filter_complex [v:0]split=3[vtemp480][vtemp720][vtemp1080];[vtemp480]format=nv12,hwupload,scale_vaapi=w=-2:h=480[vout480];[vtemp720]format=nv12,hwupload,scale_vaapi=w=-2:h=720[vout720];[vtemp1080]format=nv12,hwupload,scale_vaapi=w=-2:h=1080[vout1080] -sc_threshold 0 -max_muxing_queue_size 1024 -map_metadata -1 -pix_fmt yuv420p -map a:0 -c:a:0 copy -map [vout480] -c:v:0 h264_vaapi -quality -1 -r:v:0 30 -profile:v:0 high -level:v:0 3.1 -g:v:0 60 -b:v:0 1500000 -bufsize 3000000 -map [vout720] -c:v:1 h264_vaapi -quality -1 -r:v:1 60 -profile:v:1 high -level:v:1 3.1 -g:v:1 120 -b:v:1 3919999 -bufsize 7839998 -map [vout1080] -c:v:2 h264_vaapi -quality -1 -r:v:2 60 -profile:v:2 high -level:v:2 3.1 -g:v:2 120 -b:v:2 7280000 -bufsize 14560000 -hls_time 4 -hls_list_size 15 -hls_flags delete_segments+independent_segments+program_date_time -hls_segment_filename /data/streaming-playlists/hls/13cf7c51-a913-4efa-b9ec-c47b6b5ed905/%v-%06d.ts -master_pl_name master.m3u8 -f hls -var_stream_map a:0,agroup:Audio,default:yes v:0,agroup:Audio v:1,agroup:Audio v:2,agroup:Audio /data/streaming-playlists/hls/13cf7c51-a913-4efa-b9ec-c47b6b5ed905/%v.m3u8

I just rebuilded and pushed my image with these 2 packages : vainfo intel-media-va-driver
Can you retry ?
You can now enter in you docker container and show some infos with this command : vainfo

oh wow, ok. i have an AMD GPU in the server, 9060 XT. it has the correct permissions but if it works for you, i will check again.

ls -l /dev/dri

total 0
crw-rw----. 1 root 486 226, 0 Jul 10 13:11 card0
crw-rw----. 1 root 489 226, 128 Jul 10 13:11 renderD128

vainfo

error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can’t connect to X server!
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_17
amdgpu: unknown (family_id, chip_external_rev): (152, 65)
libva error: /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so init failed
libva info: va_openDriver() returns 2
vaInitialize failed with error code 2 (resource allocation failed),exit

so is this a permission issue? why would Owncast have permission but Peertube not?

note that i’m not streaming to Peertube. i’m only uploading local recordings of my owncast.

For SELinux, i’ve run:

setsebool -P container_use_devices true

AMD Radeon RX 9060 XT

Kernel: 6.15.4-1-default

i’ve turned VAAPI on in the web admin settings.

libva error: /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so init failed

it sound not good. How do you start the docker image ?

my vainfo is

root@b38a07fd492c:/app# vainfo
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 22.3.6 for AMD Radeon Graphics (gfx1103_r1, LLVM 15.0.6, DRM 3.61, 6.12.34-1-MANJARO)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

via a podman quadlet, but that shouldn’t matter, yeah?

i can try to build my own. precisely which items are you adding to the image?

thanks!

It depend, because the docker image must launch in privilegied mode to access to the host’s hardware. I don’t know about K8S, K3S, and sort of things, but with Nomad I need to add allow_privileged = true in the Nomad settings and in the image’s HCL :

      config {
        image      = "fredix/peertube"
        devices = [
                  {
                    host_path = "/dev/dri/renderD128"
                    container_path = "/dev/dri/renderD128"
                  }
        ]
...
}

Dockerfile_peertube

FROM chocobozzz/peertube:production-bookworm
RUN apt update && apt install mesa-va-drivers vainfo intel-media-va-driver -y
1 « J'aime »

gotcha. ya know, it’s set up the exact same way as Owncast, and that works. not sure. i’ll look into it, tho!

as long as i know it works for you, that’s good. thanks!

it works but after a while of live streaming it broke and I don’t know why. So for the moment owncast sound more stable for live streaming.