-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ffmpeg - Failed to create hwaccel device. Invalid argument #3063
Comments
Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template! |
Logs at debug level1 should provide more information. One thing to look for is permissions. /dev/dri/renderD128 in the old days was owned by root:video but in newer systems is root:render and I have no idea who owns it in a docker container. Please ensure that www-data is in whatever group has access to the device. |
@connortechnology Thanks for your response.
I did not yet find any additional info in the logging to what could be the problem, but strangely I do see the message: I find this a bit strange because all those settings have been enabled in the logging. So what did I do wrong or forget to enable/check in the logging settings? |
Probably related to #2836 ? |
Appears to be the same with v1.35.16 with AMD GPU (running on XCP-ng, Debian 10 VM with Docker and dlandon/zoneminder.master)..... some nice updates though btw :) |
I'm having exactly the same issue, also using the dlandon container (latest) on an ubuntu host. I suspected permissions issues like OP so I tried creating the render group on the guest container with the same id as the host and then adding the www-data user to that group. No change. I'm stumped at what else to try. Any ideas welcome. |
Update:
As such, it looks like adding the render group to the container, matching the host, has made some impact. I installed vainfo on the container and it outputs the following:
Still digging... |
Ok, so I think I figured it out and found a fix. It seems that VAAPI does not support new Intel chipsets and I am running an Intel 10th Gen or "Comet Lake" processor: Additionally, the new flavour from Intel seems to only be available on Ubuntu 20, not 18. As such, in addition to adding the render group (see above), in the container I had to:
With that done, I ran vainfo and confirmed it ran with no more errors, then restarted the container and checked the logs. No more errors! It's like 3.30am here now, so gonna get some sleep. Tomorrow I will repeat with a brand new container and check that I can repeat the fix, plus will check which steps are actually necessary. |
@dlandon based on my findings, I think this is an issue with your (much appreciated) containerisation of ZoneMinder rather than ZM itself. As such, I thought I would tag you as a potentially interested party. Not sure if an upgrade to Ubuntu 20 base would resolve this and also not sure how much of a PITA that will be. I'd give it a go if I was more of a whizz with containerisation. |
Damn. I just tried to reproduce the fix on a fresh container and I can't seem to repeat it :-(
|
Ok, so I figured out the workaround. The issue seems to be that newer Intel chipsets, like the ones in my 10th Gen i7, are not supported by the drivers and VA-API shipped with the version of Ubuntu that dlandon's docker image is based on (18.04 bionic). In addition, the render group is not set up by default and the user ZoneMinder runs as (www-data) does not have permissions to use /dev/dri/renderD128 To work around these issues, ssh into your running container with:
You can check that it worked by running the following also:
All being well, the vainfo command should spit out something that looks like this:
Re-boot your container and you should be good to go! While the above does solve the problem, I think it would probably be better to update dlandon's container to use a more up to date base ubuntu version. I've never built a container myself, but if I find the energy tomorrow I may fork his repo and give it a go. I can't imagine that ZoneMinder will care if we change the underlying Ubuntu version to 20. Will see how many errors the log throws out I guess! Hope this is useful. |
@kabadisha Good work and thanks for looking into this issue.
At that moment in time I could even use ffmpeg from the command line with the hwaccel enabled inside the Zoneminder docker container and functioned correctly (actual speed increase), but still gave errors in the Zoneminder application itself (running in the same container). Unfortunately I'm using a N3150 Intel processor, so a bit older generation than yours. So I'm curious if this approach will also fix my original issue. Currently a bit tight on time, but I hope to be able to give it a try somewhere early in the new year. |
FYI, I created a PR for an elegant fix to the permissions issue, inspired by how the guys at linuxserver solved the problem for their Plex image. I have also tried upgrading to the alpha focal release of phusion/baseimage. Looks like it works fine and fixes the support for newer chipsets. Will edit this comment with a link when I figure out how to get dockerhub to build it. |
@kabadisha Good work! Fingers crossed this solves my GPU issue too...... If you've built it locally you can just push the image docker hub. Quicker than waiting for it to build it. |
The phusion/baseimage for Focal is alpha. I may try to implement it in the my master docker and see if presents any problems. I do appreciate all the enthusiasm for the latest version of Ubuntu, but I can't risk support issues for the thousands of Zoneminder users that this might break. Since this is done in my spare time, I don't have a lot of time for support, especially since very few users feel my efforts are valuable enough to contribute. I'll do what I can when I can. If you go off and fork my work and do your own thing and then make it available to the general public, be prepared for all the support that will ensue. Trust me, it's a lot of thankless work. If someone is willing to fund this effort, I'd be more than happy to put more time into it. |
No problemo my friend and thanks for the advice. I will bear it in mind. I'm actually not that fussed about running the latest and greatest flavour of Ubuntu. If it ain't broke, don't fix it. As such, I tried updating to the alpha Focal release of phusion/baseimage, partly to check my hypothesis that an updated dist would remove the problem, but mostly for the intellectual exercise. It's been a brain-stretching couple of days, but fun. I taught myself the basics of how to build Docker containers today by doing this. Even got dockerhub to auto-bobulate from my forked repo.
UPDATE: @dlandon has very kindly now updated the development/alpha release of the ZoneMinder image to use the alpha Focal release of phusion/baseimage and has also included my fix for the permissions issue, which is fab. As such, if you want to try out these updates, please use that version (not my forked one, which I will now remove to avoid confusion). Source here: https://github.com/dlandon/zoneminder.master-docker I have fired it up and have no issues so far. I can confirm that it does also fix the chipset support issue I was having. HOWEVER I have not tried any of the fancy stuff like YOLO. All environment variables for those features are currently set to 0. I will try them later. @dlandon having now spent some decent time with the code myself, I can see how much effort went into it. You can expect a little late Christmas gift as soon as I locate the donate button that I'm sure I saw somewhere. Thanks for creating and maintaining this image - really appreciate it :-) Happy new year everyone! |
I'm going to update my master docker to Focal and put it out there for some testing. |
Cool - no pressure btw. Maybe just tag it as an alpha pre-release in github so that people who are pulling from :latest don't get it automatically. For those with the problem in this specific issue - you will still have permissions problems until @dlandon has had a chance to review my PR (again, no pressure intended), but you can try my fix for the permissions yourself by following the instructions in my comment on a related issue here: dlandon/zoneminder.machine.learning#105 (comment) |
Oh, BTW @dlandon the only change I had to make other than changing the base image, was to remove the ffmpeg backport, since it isn't needed any more. Focal has v4 available natively. |
I appreciate your efforts here, but give me some time to get together the master docker with focal and apply some fixes that have come up. I will then put that out there for testing so we can control the feedback and changes that will come up. You should then mark your docker as private or remove it as it will cause a lot of confusion. The two dockers I maintain are official and yours will lead to a lot of confusion and my support because my name is in yours as the maintainer. Let's keep this effort in one place and under control. |
Yes, that makes sense. I am working on a new build and will do some initial testing. I'll also include your PR for the 1.34 docker. |
Fabulous and sure thing about making my repo private. I don't want to cause any chaos :-) |
The master docker is building right now. It is updated to Focal (Ubuntu 20.04). I don't have any way to test hook processing, so hopefully someone here can give it a spin and let me know if any issues come up. |
Noice! Cheers! |
Probably a good idea. Wait until you can think straight. |
Ok, so I managed to avoid too bad a hangover thank goodness! I've also closed down my fork, removed from DockerHub and updated my comment above to avoid confusion for people.
@dlandon Apologies, I only just realised that you are maintaining a separate repo for 'master'. Not seen that before, so threw me a little. I guess it's an effective way to make sure people don't accidentally end up on an unstable release. If I have any future changes to propose, should I raise PRs against that repo instead? Cheers |
Hello, |
@kabadisha The master docker was built to try out the newest under development Zoneminder version. If it's bleeding edge stuff or new ideas, that would probably be the best place to discuss. I am preparing a new master docker that has the pre-release version 6.1.0 of ES. I'm in the final stages of testing and will release a new docker within a few hours. Give that a spin and let me know how it goes. I have no way of testing hook processing. The Focal version of Ubuntu looks like it will not present any problems. One minor issue is that the syslog-ng doesn't seem to be the latest version and I haven't been able to find an appropriate package. Shouldn't be a show stopper though. I suspect phusion will update it in the next release. @multijohn It's my understanding that Ubuntu 20.04 is needed for the latest hardware drivers. |
Hey @multijohn, However, you may find that the version of Ubuntu you are using does not have support for the version of Intel drivers and vaapi to play nice with your processor. HOWEVER any performane increase is likely to be marginal at best, so I wouldn't bother if your system is coping fine at the moment. |
@dlandon will do! Initially I just want to send a notification to discord with the video of the event, but later I will probably play with the ML stuff for funsies. |
@TechNovation01 maybe we should close this issue now that we know why it is happening and how to fix it? Let us know if the fix worked for you too. |
Morning... all appears to be working with the latest master. Object detection is detecting and not complaining. Going to check a fresh install now and also try with my AMD GPU. |
Just built a new docker that has the ES 6.1.0 prelease installed. Give it a try. |
With the version built a 14 hours ago AMD GPU acceleration is working. Verified by watching This is a VM with the GPU passed thought, then passed through to Docker so its the only things using it (/dri/1 will probably be 0 in most cases). This issue appears resolved. Will try the latest build now and update on the other issues in the relative threads. |
Hey Guys, When I enable hardware decoding on an rtsp (h264) stream, I sporadically get errors like this: Looking at the code itself, it seems to be an issue when transferring data from the GPU to the CPU. Any ideas for how I might diagnose further? |
Foolishly, I just realised I should have enabled debug to get more juicy logs. Just did that now:
Based on the above, I am beginning to suspect that these interruptions are caused by the source camera having some kind of wobble, which causes the capture daemon to restart. Unless anyone has any better ideas, I'll chalk it up to that. For context, the source cameras are Raspberry Pis with camera modules running motionEyeOS in 'Fast Network Camera' mode, which basically just takes the native 1080p h.264 stream output by the camera module and spits it out on an rtsp stream. Works rather well for such cheap devices. It was also a hell of a lot easier and more reliable than trying to stream directly using ffmpeg and some other libraries. Burned a full day down that particular rabbit hole... |
I would also be interested if anyone on this thread saw any performance benefit from getting the hardware acceleration working. |
@kabadisha yeah similar story here. Which is good in a way becaise I'm thinking of moving my ZoneMinder into Kubernetes (which could be fun!) and not having it tied to a GPU will make much more sense. |
Been doing some testing again on the zoneminder.master-docker with my configuration.
Still trying some other checks/changes, but with my CPU it is a bit slow on re-building the docker container (opencv takes ages) and that is why I thought some hwaccel could help my system (but listening on this thread it may not bring the boost I'm hoping for). |
I no longer have the error messages, so it appears to have been fixed. I'm however happy to see that in release v1.35 the option is introduced to disable Decoding (option |
Environment:
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04).
Describe the bug
Ffmpeg hardware acceleration settings for monitor decoding are not correctly applied and thereby remain disabled.
To Reproduce
Steps to reproduce the behavior:
vaapi
& DecoderHWAccelDevice =/dev/dri/renderD128
ERR | Failed to create hwaccel device. Invalid argument | zm_ffmpeg_camera.cpp | 539
Other Steps taken to identify issue
/dev/dri/renderD128
available in the docker container./dev/dri/renderD128
is owned byrender
and added this group to the default zoneminder user www-data.docker run -it --user www-data zoneminder /bin/bash
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i 1000-video.mp4 -f null -
and this runs succesful without an error and outputs a speed of 207x, while if I run the same command without the hardware acceleration settings it only achieves a speed of 66x and finishes quite a bit slower.
zoneminder/src/zm_ffmpeg_camera.cpp
Lines 542 to 547 in 1173f61
Expected behavior
Hardware acceleration settings are applied in line with Zoneminder help pop-up and should enable hardware acceleration support without error message.
Debug Logs
So ffmpeg hardware acceleration is confirmed to work correctly within the container, but I'm having problems with an Invalid Argument being passed to av_hwdevice_ctx_create in zm_ffmpeg_camera.cpp.
I hope this helps sufficiently to support in diagnosing the issue.
The text was updated successfully, but these errors were encountered: