High cpu usage capturing single camera

Forum for questions and support relating to the 1.28.x releases only.
Locked
smee204
Posts: 4
Joined: Thu Jul 16, 2015 7:56 am

High cpu usage capturing single camera

Post by smee204 »

I have a Hosafe 2MB2 1080p IP camera connected to zoneminder via ffmpeg/RTSP.
I am finding that my cpu usage just for capturing is ~25%.
I have set the camera as a Monitor, 1920x1080 resolution, 5fps.
Running Centos 7 on i3-2100 with 4GB ram.

Any idea why the cpu usage is so high?
Linwood
Posts: 75
Joined: Thu Jun 25, 2015 6:40 pm

Re: High cpu usage capturing single camera

Post by Linwood »

I just did some testing on a Q6600 system, and if memory serves the I3-2100 is somewhere near the Q6600, both a bit older and slower. I have 6GB and was running five 3mp (2048x1536) cameras at 4fps, but saving at only 2fps. That's still more resolution and twice the save rate. Also 4 of the 5 were running motion detection. I found I was consuming about 25% of the available CPU resources as well, though obviously getting more work done.

Are you sure the 25% is 25% of 100%? One thing unix (and I am new to unix) does confusingly is report CPU. That chip shows as either 2 or 4 cores depending on hyperthreading, if I recall, so that might be 25% of 100%, of 200%, or of 400% depending on the display choices in "top" and bios and your choice of program to measure. The former sounds high, the middle one a tad high but possible, and the latter more likely.

Are you sure it's 25% of 100%?

I should note I am running remote/rtsp not ffmpeg, though I have tried both and did not see huge differences (though I did get about a half second more latency in ffmpeg which made me think it may have more overhead).
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: High cpu usage capturing single camera

Post by knight-of-ni »

Unfortunately, that is about right.
You simply cannot get many high megapixel cameras to work using zoneminder on an average desktop pc.

The root cause of the problem is zoneminder itself. It is transcoding the incoming H264 stream, in real time, into many jpeg files. This used to be good thing back in the day when IP cameras streamed mjpeg, but has become a burden with today's h264 cameras. It is something we are working on.

In the meantime, the best thing you can do is upgrade your hardware. Get a machine with as many cpu cores as you can afford. Hyperthreaded cores do not count. Zoneminder will spread the load across all the cores quite evenly.

In addition to lowering the frame rate, which you have already done, you can try to work around the problem by:
- change the cameras to stream mjpeg, at the cost of network bandwidth and disk i/o (caution: this can actually make things worse in some circumstances)
- turn off motion detection or reduce the size of the motion zones
- lower the resolution
- experiment with these source types to find the one that uses the lowest cpu on your system: rtsp, ffmpeg, libvlc
- stop non-essential, non-zoneminder processes from running
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
smee204
Posts: 4
Joined: Thu Jul 16, 2015 7:56 am

Re: High cpu usage capturing single camera

Post by smee204 »

Linwood wrote:I just did some testing on a Q6600 system, and if memory serves the I3-2100 is somewhere near the Q6600, both a bit older and slower. I have 6GB and was running five 3mp (2048x1536) cameras at 4fps, but saving at only 2fps. That's still more resolution and twice the save rate. Also 4 of the 5 were running motion detection. I found I was consuming about 25% of the available CPU resources as well, though obviously getting more work done.

Are you sure the 25% is 25% of 100%? One thing unix (and I am new to unix) does confusingly is report CPU. That chip shows as either 2 or 4 cores depending on hyperthreading, if I recall, so that might be 25% of 100%, of 200%, or of 400% depending on the display choices in "top" and bios and your choice of program to measure. The former sounds high, the middle one a tad high but possible, and the latter more likely.

Are you sure it's 25% of 100%?

I should note I am running remote/rtsp not ffmpeg, though I have tried both and did not see huge differences (though I did get about a half second more latency in ffmpeg which made me think it may have more overhead).
I just double checked and it is definitely 25% of 100%, so it is using a whole core just for a single camera. :(
User avatar
gnocera
Posts: 34
Joined: Thu Jun 04, 2015 6:31 pm

Re: High cpu usage capturing single camera

Post by gnocera »

Hello.

Knnigget is right. You can not expect zoneminder to work with your high super resolution cameras, without hammer your little i3 processor.
Even if you decide for i7 you will be in troubles, believe me.
First review what you need and what you do not need from zoneminder, remember that zoneminder is a serious video server with a lot of functions.

If you are looking for saving videos at high resolutions I recommend you to try a strong processor, like AMD OPTERON 4000 or 6000, XEON.
For good live streaming you can also buy a nice video card, it should help operator for nice live view.

And always check how much RAM is consuming your zoneminder. If RAM become full at some point, your hardware will force to do swap on hard disk This is reeeeeeaaallly bad for video servers. So try to set your RAM amount in order to never do swap.

Regards,

Giuseppe
Locked