ZM hardware video accelerated

Add any particular hints or tricks you have found to help with your ZoneMinder experience.
Post Reply
User avatar
zd59
Posts: 51
Joined: Wed Jan 18, 2017 1:39 pm
Location: EU - Slovenia

ZM hardware video accelerated

Post by zd59 » Mon Aug 14, 2017 11:54 am

Hi!

As all modern Intel CPUs contain hardware video acceleration and it is supported in ffmpeg, I wonder, how to enable that in ZM to offload CPU.
It's about h.264 and h.265 video streams processing, and https://trac.ffmpeg.org/wiki/Hardware/QuickSync

Any idea?

XabiX
Posts: 13
Joined: Thu Feb 02, 2017 4:31 pm

Re: ZM hardware video accelerated

Post by XabiX » Thu Oct 19, 2017 2:34 pm

Hello

I am interested to know as I was using ZM but my CPU with 5 CAMs was 80% with an i7 7700 so I was either thinking to buy an external video card which I am not sure should bring that much optimization if ZM was using intel HD.

Maybe I need to install Windows with Blue Iris as it seems to be working with intel HD but I hate Windows for servers :)

Merci
XabiX

User avatar
zd59
Posts: 51
Joined: Wed Jan 18, 2017 1:39 pm
Location: EU - Slovenia

Re: ZM hardware video accelerated

Post by zd59 » Fri Oct 20, 2017 8:20 am

Hi XabiX!

As I later discovered, ZM do not have any video acceleration options to set up. All is done in ffmpeg dependent library.
The library must be recent and HW acceleration must be enabled at compile time. Distribution I use did not have HW acceleration enabled, so I asked the ffmpeg lib mantainer add that - done in a days!

CPU usage highly depends of ZM settings for camera. Modern h.265 video codec is "Zoneminders CPU killer". Do not use it. Best is mjpeg or h.264.
ZM uses jpeg pictures for a motion detection and events recording. Take a look into events folder. So video from camera must be transformed to jpeg.
To lower CPU usage select source = remote or ffmpeg in camera setup. Also select 32 bit Target color space. To additional offload, you select low FPS. It's enough to have 5 FPS.
To further offload CPU, for a motion detection and record, I setup low resolution camera stream (VGA or PAL) for a moton detection, and link to it "nodect" high resolution camera video stream. And for a motion detection try to create minimum possible zones (and they should be small).

The above is my experience and tests with ZM-1.30.0 on Debian with two cameras, one 3MP h.264 and one with 4MP h.265.
Take a look a 24 hour (snapshot right now) CPU load on my system. CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz with 8GB RAM and SSD disk for OS, events are stored on USB3 attached HD

I'm interested of success of my optimisation method, so please report the results here, if you are willing to use them.

Regards
Attachments
Kernel_load.jpg
Kernel_load.jpg (58.53 KiB) Viewed 296 times

XabiX
Posts: 13
Joined: Thu Feb 02, 2017 4:31 pm

Re: ZM hardware video accelerated

Post by XabiX » Fri Oct 20, 2017 9:43 am

Bonjour ZD59,

I am under Ubuntu 16.04.3 and using the default library ffmpeg version 7:3.2.4-2~xenial maintained by djcj@gmx.de. Not sure if this is really the one which includes or not HW decoding. My CPU is an i7-7700T which should normally be overkilled.

At the moment my CAMs network is down and didn't receive the new ones so I can do test but I will report. I am also using the MaxFPS to 26 (and ffmpeg with 24bits color).

I did solve quite some issues with the CPU yesterday evening (viewtopic.php?t=25790) so I am now just looking to get the POE switch back so I can test:).

Still running too high for not much but will test with the cameras:

Code: Select all

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command                                                                                                                                                                                          
 4990 www-data   20   0  637M  207M  192M S [b]20.4[/b]  1.3  2h50:34 /usr/bin/zmc -m 5                                                                                                                                                                                
 5129 www-data   20   0  637M  204M  192M S [b]19.7[/b]  1.3  2h50:31 /usr/bin/zmc -m 7
 5161 www-data   20   0  637M  205M  192M S [b]19.7[/b]  1.3  2h50:43 /usr/bin/zmc -m 8
 5018 www-data   20   0  637M  207M  192M S [b]19.7[/b]  1.3  2h51:25 /usr/bin/zmc -m 6
Total load 1.19 with no cameras :)

Thanks for sharing your findinds. And hopefully with the right library I should be all set too!

For me the cameras do the detection and record through samba when they detect an event. So I am using ZM as a central management viewer. So even less demanding. If CPU goes down I may do the zones and detections in ZM.

Merci and have a good WE
XabiX

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests