Jump to content

Problems activating VAAPI in docker container


MisterDigit

Recommended Posts

MisterDigit

Hello all,

I am a new emby user and I am trying to enable hardware transcoding in emby. I have a emby premium plan.

Emby is running in a docker container on my DS416Play. I've forwarded the /dev/dri device into the container and ffdetect finds the device.

Unfortunately ffdetect says "IsEnabled=0" and there is not hardware transcoding offered in the webinterface

[DEVICE]                                                                                                                                                  
DeviceIndex=0                                                                                                                                             
DEVICEINFO:VendorName=Intel Corporation                                                                                                                   
DEVICEINFO:DeviceName=Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller                                                  
DEVICEINFO:SubsytemVendorName=Intel Corporation                                                                                                           
DEVICEINFO:VendorId=32902                                                                                                                                 
DEVICEINFO:DeviceId=8881                                                                                                                                  
DEVICEINFO:SubsytemVendorId=32902                                                                                                                         
DEVICEINFO:SubsytemDeviceId=29296                                                                                                                         
DEVICEINFO:DevPath=/sys/bus/pci/devices/0000:00:02.0                                                                                                      
DEVICEINFO:DrmCard=/dev/dri/card0                                                                                                                         
DEVICEINFO:DrmRender=/dev/dri/renderD128                                                                                                                  
DEVICEINFO:IsEnabled=0                                                                                                                                    
DEVICEINFO:IsBootVga=1                                                                                                                                    
DEVICEINFO:ApiVersionMajor=1                                                                                                                              
DEVICEINFO:ApiVersionMinor=7                                                                                                                              
DEVICEINFO:Driver=Intel i965 driver for Intel(R) CherryView - 2.4.0   

19056532_Bildschirmfoto2020-10-07um10_05_14.thumb.png.ef4fb0452488227b29a55669f125bd2b.png

But when I run emby as root inside the container (UID 0, GID 0) it is working:

[DEVICE]                                                                                                                                                  
DeviceIndex=0                                                                                                                                             
DEVICEINFO:VendorName=Intel Corporation                                                                                                                   
DEVICEINFO:DeviceName=Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller                                                  
DEVICEINFO:SubsytemVendorName=Intel Corporation                                                                                                           
DEVICEINFO:VendorId=32902                                                                                                                                 
DEVICEINFO:DeviceId=8881                                                                                                                                  
DEVICEINFO:SubsytemVendorId=32902                                                                                                                         
DEVICEINFO:SubsytemDeviceId=29296                                                                                                                         
DEVICEINFO:DevPath=/sys/bus/pci/devices/0000:00:02.0                                                                                                      
DEVICEINFO:DrmCard=/dev/dri/card0                                                                                                                         
DEVICEINFO:DrmRender=/dev/dri/renderD128                                                                                                                  
DEVICEINFO:IsEnabled=1                                                                                                                                    
DEVICEINFO:IsBootVga=1                                                                                                                                    
DEVICEINFO:ApiVersionMajor=1                                                                                                                              
DEVICEINFO:ApiVersionMinor=7                                                                                                                              
DEVICEINFO:Driver=Intel i965 driver for Intel(R) CherryView - 2.4.0   
 
grafik.thumb.png.162c4a969aa2476acaa57aa9dbcbd86d.png

Running emby is root is not a really good solution, what can I do to get hardware transcoding working with emby/ffmpeg running as a non-root user ?

Best regards

MisterDigit

 

 

Edited by MisterDigit
Link to comment
Share on other sites

Hi, I wouldn't pay much attention to IsEnabled because we ignore that on Synology. At the very least you will need to make sure the user it is running as is added to the video group. have you done that?

Link to comment
Share on other sites

MisterDigit

Hello Luke,

thanks for the really fast answer. Probably you've missed some important detail in my description: I am running emby in a docker container on the DS416play

Ignoring the flag is not enabled in your docker package, only in the spk.

I've added "-ignore_vaapi_enabled_flag" in your docker container by modifying the start script /etc/services.d/emby-server/run:

s6-applyuidgid -U /system/EmbyServer \                                                                                                                    
    -programdata /config \                                                                                                                                
    -ffdetect /bin/ffdetect \                                                                                                                             
    -ffmpeg /bin/ffmpeg \                                                                                                                                 
    -ffprobe /bin/ffprobe \                                                                                                                               
    -ignore_vaapi_enabled_flag \                                                                                                                          
    -restartexitcode 3  
 
And yay, then it is working. But, of course, the change will be gone as soon as I update the container.
Anyhow possible that you add an option to enable this flag by setting some parameter in the docker environment ?
 
Best regards
 MisterDigit
Edited by MisterDigit
Link to comment
Share on other sites

MisterDigit

Perfect, thanks.

>Why docker and not spk ?

- Better encapsulated, will not write any files into the host
- no dependency to any host features (see "problems" with DSM 7 and current emby spk)

When will the option be available ?

Best regards

MisterDigit

Link to comment
Share on other sites

Actually I'd rather try and just apply this automatically if we can detect we're running on Synology. Thanks.

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
On 2/20/2021 at 12:59 PM, Luke said:

Actually I'd rather try and just apply this automatically if we can detect we're running on Synology. Thanks.

@MisterDigit we've added this automatic detection into our Docker beta package if you'd like to try it. Thanks.

  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...
MisterDigit

@Luke

Thanks for your efforts but unfortunately your current "automatic detection" solution is not working:

if uname -a | grep -q synology; then
...
fi

It is not working because "uname -a" inside the docker container doesn't reporting anything with synology in its output:

Linux emby-embyserver1 3.10.108 #41890 SMP Thu Jul 15 03:41:52 CST 2021 x86_64 GNU/Linux

(in the host OS this is reported: Linux fs1 3.10.108 #41890 SMP Thu Jul 15 03:41:52 CST 2021 x86_64 GNU/Linux synology_braswell_416play)

Perhaps easiest solution will by evaluation an environment variable like

if "$IGNORE_VAAPI_ENABLED_FLAG" -eq "1"; then
...
fi

Best regards
MisterDigit

Link to comment
Share on other sites

  • 4 months later...
MisterDigit

Hi,

A few months have passed, unfortunately the proposed change didn't get into the latest docker image. So here once again the requested change:

Please change

if uname -a | grep -q synology; then

to

if [ "$IGNORE_VAAPI_ENABLED_FLAG" -eq "1" ]; then

So that hardware-acceleration can be activated in Docker on Synology NAS by setting an environment variable.

Best regards
  MisterDigit

Link to comment
Share on other sites

Hi, this is for the official docker release here correct? https://hub.docker.com/r/emby/embyserver

What UID, GID and GIDLIST are you using in your setup.  You would need to make sure the IDs include access to groups video & render.

Did you validate they are correct on your system as these are values that will differ system to system.
I do agree with you the uname line isn't going to work in docker as that info is abstract.

Regardless you would be far better off installing the normal package designed for Synology and not running Emby through docker as you pay a performance penalty for doing that across the board. You give up CPU and GPU optimizations as it's abstract to docker. You likely don't have QuickSync either which on my system is much faster than VAAPI as well.
image.png.afec68d4f1b6bf795889b00cf42b319a.png

Docker really should be used for running programs like this long term.  It's great for testing or sandboxing but for deployment you want as close to bare-metal as possible to get CPU/GPU optimizations, Direct IO access, much faster memory access, 2 or 3 layers removed from network and disk access. Not to mention how it greatly simplifies setting permissions.  There really is no reason to run this in docker on Synology as you just cause yourself grief and lose out on speed and functionality.

Docker versions of software should (besides testing) only be used when native apps aren't available as anything running in docker isn't going to be optimized for the platform it's running on, as it can't be.

Link to comment
Share on other sites

MisterDigit

Hello,

thanks for your response.

(1) I don't share your concerns regarding loss of CPU/GPU optimizations, degraded performance in memory access, recognizable performance in disk access as the underlying docker technology like cgroups, namespaces is very effective and has very little overhead. As the docker container has direct access to /dev/dri it also has the possibility to use hardware-accel of the GPU :)

(2) I really like having programs/packages separated from my NAS environment, from my current experience emby is working very smoothly on my NAS inside the docker container. The only problem is the missing option "-ignore_vaapi_enabled_flag". Hopefully you can extend your docker init-script to respect i.e. an environemnt variable like $IGNORE_VAAPI_ENABLED_FLAG to be able to activate that flag.

(3) Thanks for pointing me to Quick-Sync. Unfortunately there seem to be some issues with QuickSync on my NAS DS416Play (Celeron N3060-based). Here the output of ffdectect.
Does it mean Quick-Sync cannot be used by Emby on my NAS ?

 

    "Devices": [
        {
            "DeviceIndex": 0,
            "DeviceInfo": {
Begin GetVaAdapterInfo
Found 17 device entries
Begin get_nodes
Found 3 drm entries
End GetVaAdapterInfo
                "VendorName": "Intel Corporation",
                "DeviceName": "Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller",
                "SubsytemVendorName": "Intel Corporation",
                "VendorId": 32902,
                "DeviceId": 8881,
                "SubsytemVendorId": 32902,
                "SubsytemDeviceId": 29296,
                "DevPath": "/sys/bus/pci/devices/0000:00:02.0",
                "DrmCard": "/dev/dri/card0",
                "DrmRender": "/dev/dri/renderD128",
                "IsEnabled": 1,
Initialize MFX session: API version is 1.34, implementation version is 1.34
                "IsBootVga": 1,
                "ApiVersionMajor": 1,
                "ApiVersionMinor": 34
            },
            "Decoders": [
                {
                    "CodecName": "mpeg2video",
                    "CodecId": 843534413,
                    "MinWidth": 1,
                    "MinHeight": 1,
                    "MaxWidth": 4096,
                    "MaxHeight": 4096,
                    "WidthAlignment": 16,
                    "HeightAlignment": 16,
                    "Profiles": [
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_MPEG2_SIMPLE
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_MPEG2_MAIN
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_MPEG2_HIGH

                    ]
                },
                {
                    "CodecName": "vc1",
                    "CodecId": 540099414,
                    "MinWidth": 16,
                    "MinHeight": 16,
                    "MaxWidth": 16384,
                    "MaxHeight": 16384,
                    "WidthAlignment": 16,
                    "HeightAlignment": 16,
                    "Profiles": [
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_VC1_SIMPLE
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_VC1_MAIN
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_VC1_ADVANCED

                    ]
                },
                {
                    "CodecName": "h264",
                    "CodecId": 541283905,
                    "MinWidth": 16,
                    "MinHeight": 16,
                    "MaxWidth": 16384,
                    "MaxHeight": 16384,
                    "WidthAlignment": 16,
                    "HeightAlignment": 16,
                    "Profiles": [
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_BASELINE
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_MAIN
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_EXTENDED
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_HIGH
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_HIGH10
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_HIGH_422
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_CONSTRAINED_BASELINE
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_CONSTRAINED_HIGH
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_AVC_PROGRESSIVE_HIGH

                    ]
                },
                {
                    "CodecName": "hevc",
                    "CodecId": 1129727304,
                    "MinWidth": 16,
                    "MinHeight": 16,
                    "MaxWidth": 16384,
                    "MaxHeight": 16384,
                    "WidthAlignment": 16,
                    "HeightAlignment": 16,
                    "Profiles": [
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_HEVC_MAIN
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_HEVC_MAIN10
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_HEVC_MAINSP
AddDecoderProfiles - Profile not supported (1): MFX_PROFILE_HEVC_REXT

                    ]
AddDecoders - Codec not supported: vp8
AddDecoders - Codec not supported: vp9
                }
            ],

 

Best regards
 MrDigit

Link to comment
Share on other sites

It's not unusual to see profiles not supported. I just took a quick peek at this file from my 10th gen i7 with QuickSync and Nvidia RTX 2070 and see unsupported profiles as well.

What I don't know is how much access it will have via docker or if there is any difference based on the way you have it setup.

As a quick test you could find out for sure by doing a quick install of the package on Synology, grab the hardware file and then uninstall the package.

That would let you compare the difference if any GPU wise. I'd be interested in knowing myself.

Link to comment
Share on other sites

MisterDigit

ffdetect on "bare metal" (synology package) and ffdetect in docker (docker package) output the same result, as both have same access to /dev/dri this also sounds reasonable to me.

The processor is Braswell-based, base on Intels website it supports QuickSync (https://ark.intel.com/content/www/de/de/ark/products/91832/intel-celeron-processor-n3060-2m-cache-up-to-2-48-ghz.html), ffdetect says that no supported decoding-profiles are available :(

Link to comment
Share on other sites

Thanks for doing that.  That seemed like a good test to rule out any abstraction from hardware.

Yes if that's your proc then it would seem to support QuickSync.  I see a lot of people complaining QuickSync not working in DSM 7 but did in DSM 6.
I'd not go down that path myself without checking if it works outside of docker first.

It could be Synology has an old driver loaded or a half dozen other reasons.

Link to comment
Share on other sites

  • 1 month later...

the ignore_vaapi_enabled_flag is baked into our Docker container now, so that it automatically gets added when it detects the Synology platform. As a result, you shouldn't have to mess with that anymore. However our packaging developer does have some additional information though on what you need to do:

Quote

 I was able to get VAAPI on my synology via docker. Do note however that the docker app in synology is very limited and doesn't let you set up the required devices, so users who chose docker over the native app for some reason will have to upload a docker-compose file on their nas, and run docker-compose via SSH for it to work.

 

Link to comment
Share on other sites

  • 2 years later...
Zoomer88

Hi everyone! I too prefer running Emby from inside the docker container. However, here in 2024 I'm facing the same issue, it seems. I, too, have a braswell-based Synology (DS216+ II) and VAAPI isn't available from the web frontend. Furthermore, I see that the IGNORE_VAAPI_ENABLED_FLAG isn't added to the command line and ffdetect detects /dev/dri as "IsEnabled": 0.

The container is freshly installed latest emby/embyserver and the Emby server version is 4.8.3.0.

I'm also attaching the hardware detection and server logs just in case. (dev/dri is forwarded to the docker container via "--device=/dev/dri:/dev/dri" line and seems to be working properly according to the hardware detection log).

What's the status on this issue? Has the flag been deprecated? If not, what's the best way to add it to the command line? Thanks!

hardware_detection-63846726712.txt embyserver.txt

Edited by Zoomer88
Link to comment
Share on other sites

On 3/22/2024 at 1:34 PM, Zoomer88 said:

Hi everyone! I too prefer running Emby from inside the docker container. However, here in 2024 I'm facing the same issue, it seems. I, too, have a braswell-based Synology (DS216+ II) and VAAPI isn't available from the web frontend. Furthermore, I see that the IGNORE_VAAPI_ENABLED_FLAG isn't added to the command line and ffdetect detects /dev/dri as "IsEnabled": 0.

The container is freshly installed latest emby/embyserver and the Emby server version is 4.8.3.0.

I'm also attaching the hardware detection and server logs just in case. (dev/dri is forwarded to the docker container via "--device=/dev/dri:/dev/dri" line and seems to be working properly according to the hardware detection log).

What's the status on this issue? Has the flag been deprecated? If not, what's the best way to add it to the command line? Thanks!

hardware_detection-63846726712.txt 171.63 kB · 0 downloads embyserver.txt 816.33 kB · 0 downloads

HI, that flag is only used in the Synology package, where it is specifically needed. It is not used in Docker. Ideally our Docker package could detect that it's on Synology and set the value, but that proved to be tricky. We'll have to see if there's a way we can allow this to be configured.

Link to comment
Share on other sites

alucryd

We have a synology autodetection in place, but it looks like it might not work in your case. Could you run `uname -a` over SSH and post the output just to confirm, but I already see from the server log that it does not contain the token we're looking for.

Link to comment
Share on other sites

alucryd

@Zoomer88Could you give the latest beta docker image a try? I added a `IGNORE_VAAPI_ENABLED_FLAG` env variable, setting it to the string `true` should pass the associated flag to emby.

  • Like 1
Link to comment
Share on other sites

Zoomer88

Hi, @alucryd! Thanks for looking into it. I've checked the knowledge base, download page and docker hub and can't seem to find the links to the beta container. Am I missing something? Could you please lead my hand to the one? On the docker hub I can only see those: https://registry.hub.docker.com/u/emby

The emby/embyserver was updated like a day ago, but this isn't a beta, right?

Sorry if those are stupid questions, I'm pretty new to emby :)

Link to comment
Share on other sites

alucryd

No worries, you were on the right track, to get the beta docker you just need to pull the beta tag:

emby/embyserver:beta
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...