motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
4.01k stars 662 forks source link

VA-API supported? #2630

Open aaronouthier opened 2 years ago

aaronouthier commented 2 years ago

Hello, I am wondering if Intel Graphics acceleration is supported in the dev branch?

I am considering moving my docker setup with Home Assistant + MotionEye from an oDroid XU4 (no H/w accel.) to a Zimaboard (Intel Apollo chipset/CPU with Intel graphics).

xjon685 commented 2 years ago

Hi, although im not qualified to give you an answer, I thought I would share my experience. I have n5095 mini PC, Rpi4 and Xu4 that i have used for various projects that need video encoding (motioneye, handbrake and jellyfin). Getting Intel Quick sync or VA-API is apparently possible and there are many forum threads out there to show how to make it work for you, but it's a bit of a mess in some Linux distros, and there are no guarantees I had real issues in Debain / OMV.

Personally I never got any hardware acceleration to work in MotioneyeOS standalone, motioneye (HACS) within HomeAssistant containerized or within in a docker container on my Intel N5095.

Also those Zimaboard boards look quite slow, the lowest model is the same speed as Xu4 which is very old now and the highest is slower than an odroid N2+. They do look interesting tho, but not sure it's much, if any of an upgrade considering they are x86. When comparing the Intel CPU's the zimaboard uses in Geekbench 5 with the Xu4 or N2+ the results are mixed at best.

https://browser.geekbench.com/search?utf8=%E2%9C%93&q=n3450

aaronouthier commented 2 years ago

Uhh, yeah. I know the ZimaBoard isn’t going to be incredibly zippy. It’s a Celeron, and it’s passively cooled. Thank you for your input, but I just wanted to know whether the MotionEye code supports hardware acceleration.

It wouldn’t matter if I had a Nvidia 3060 in my rig. If the code isn’t made to use it for encoding, then it is just a display adapter.

FWIW: I just recently found out you need to pass through the /dev/dri/renderD128 device into the docker container before it will see & use the HW encoder.

xjon685 commented 2 years ago

yep /dev/dri/renderD128 doesn't work at least in debian 11 running OMV6. or if it does work, it's not as simple as just adding a device parameter in the docker compose yaml file. I spent a week trying to get either quick-sync or vaapi to work on n5095 SoC messing with various driver conf files. You might have better luck on a more mature celeron though.

zagrim commented 2 years ago

Whether any hardware acceleration is supported depends mostly on the motion and/or ffmpeg binaries on your distro, but perhaps also to some extent in ME on the side of whether a given codec & HW accel option is displayed (I mean there are some has_<codec>_<hwsupport> methods in motionctl.py and there's nothing for VA-API). Unfortunately I can't remember off the top of my head in which operation each of those binaries were relevant (motion does reading of video stream, so it is relevant for decoding, while ffmpeg is used for recording video files and thus is relevant for encoding?)...

As for ffmepg, you can check with ffmpeg -codecs. I didn't immediately find any way to do the same with motion, though.

aaronouthier commented 2 years ago

After some research, it seems that besides needing access to /dev/dri/renderD128, one needs to add “netcam_decoder vaapi” under ‘Video Device’->’Extra Options box’.

I have not verified this makes any difference, however.

aaronouthier commented 2 years ago

Info source: https://github.com/Motion-Project/motion/discussions/1372 plus my own trial and error.

zagrim commented 2 years ago

You should've referenced all that right from the start, or provided here all the details given there so I wouldn't have been guessing that much :laughing:

But ok, so it seems that firstly Motion 4.4 is required (did I read that right?). Luckily that should now be supported in the current dev branch of MotionEye. There are instructions for installing ME from dev branch in the dev branch README.md file: https://github.com/motioneye-project/motioneye/tree/dev . As for the docker image built from dev branch, I think those should be available here: https://github.com/motioneye-project/motioneye/pkgs/container/motioneye . However, I think those pre-built images don't have Motion 4.4 installed, so you would presumably have to build your own by first cloning the repo, switching to dev branch, and then modifying the required files in motioneye/docker/ (sorry for not being more specific since I'm not that experienced with docker) and following the README.md in that directory for building you own image.

aaronouthier commented 2 years ago

I simply used the Dev branch of MotionEye, and it already has Motion 4.4.0 included. I’m using docker-compose, with an edited .yml file.