Reducing CPU

Forum for questions and support relating to the 1.29.x releases only.
Locked
Zmjm15
Posts: 90
Joined: Fri Jul 31, 2015 7:56 pm

Reducing CPU

Post by Zmjm15 »

Hi guys,

I'm looking for a way to reduce the CPU when motion detection is enabled.

So i've looked at how much CPU is being used when MoDect is enabled and when there is lots of motion going on and for my setup this comes to about 35%. When i switch it to "Monitor" it only takes up about 8%. When idle about the same CPU is used.

This makes me think that the motion is being analyzed quite alot and causes the CPU to spike whilst it's happening, so i was wondering if there is anyway i can turn off the analyzing of the motion once its already detected so its not as CPU intensive and still have it record the motion anyway?

Many thanks
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Reducing CPU

Post by SteveGilvarry »

No way currently, I mean how would it know when the motion stopped, and when it should start monitoring motion again?
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
Zmjm15
Posts: 90
Joined: Fri Jul 31, 2015 7:56 pm

Re: Reducing CPU

Post by Zmjm15 »

Hmm good point, maybe send out signals every few moments to see if the motion has stopped rather than constantly analyzing it? I think id prefer to have less CPU usage and deal with slightly less accurate conclusions of events. As when its monitoring idle images it is not using that much cpu, so if it can kick in once the motion has been detected, that would be saving massive amounts.
dmitripr
Posts: 17
Joined: Fri May 06, 2016 4:31 am

Re: Reducing CPU

Post by dmitripr »

You could have your camera do the motion detection (if it supports it). Then use a script to check if camera is in alarm state every 1-2 seconds, if it's in alarm state, then use zmtrigger to trigger alarm in ZM and start recording, stop recording once alarm state ends. I saw a ZM wiki how-to on this somewhere. Just make sure your ZM ring buffer is longer than whatever your alarm check frequency is, so you don't miss the beginning of what triggered the alarm.

BUT ... what's wrong with CPU running at 35% ? (unless it's an older CPU and consumes quite a bit of electricity, then I can see the point).
Zmjm15
Posts: 90
Joined: Fri Jul 31, 2015 7:56 pm

Re: Reducing CPU

Post by Zmjm15 »

Thanks for posting back,

Does anyone have amy generics scripts to use their cameras motion detection, or is this going to be specific to each camera?

I wouldn't mind the cpu being at 35% but I am looking at adding more cameras and not sure if the cpu on the machine could cope. If I could offload the cpu and use the camera's then I think it would be fine as the ram is doing fine.

Many thanks
dmitripr
Posts: 17
Joined: Fri May 06, 2016 4:31 am

Re: Reducing CPU

Post by dmitripr »

It's going to be specific to each camera.

In my experience, analysis via ZM doesn't actually take a lot of CPU, most of CPU is taken by FFMPEG for image capture. I also was looking to offset analysis to the camera CPU, but considered the fact that I'd need to write scripts to do this and then support those scripts in case of changes later on. And all that would save me (for 2 cameras @ 1080p) is 5% of CPU. I don't think it's worth it. My 2 cents.

Run the 'top' command on your ZM server and see how much of CPU ZMA process(es) use(s).
Zmjm15
Posts: 90
Joined: Fri Jul 31, 2015 7:56 pm

Re: Reducing CPU

Post by Zmjm15 »

I will test this out soon thanks for your advice, if ffmpeg is the culprit, any ideas on how to reduce the cpu usage on that?

Many thanks
dmitripr
Posts: 17
Joined: Fri May 06, 2016 4:31 am

Re: Reducing CPU

Post by dmitripr »

It really comes down to the size and quality of the incoming stream: video size, frame rate, color or B&W, Mbps of the compressed stream.
Locked