Hi there
I have a set up with 3 Axis 2400 cameras, which is working pretty much fine. I have noticed some slightly odd behaviour in terms of CPU ultilisation when changing frame rates:
- When I set the frame rate maximum to something reasonable (like 5 FPS), I have a single zmc process taking about 60-70% of the CPU (as reported by top). This is on a P4 2.4 GHz. The camera captures at a rate between 3 - 5 fps using this setting.
- When I leave the max fps to 0 (i.e no max fps), Zoneminder cheerfully captures at about 20 - 25 fps, with zmc taking about 15% of the CPU
- I cannot run all three cameras at the same time if I throttle to 5 fps - but they will run just fine capturing at 20 - 25 fps. With all three cameras running, I have 3 zmcs, totalling about 60% CPU.
This behaviour is repeatable on two setups:
1) Redhat 8.0, zm 1.19.1, Athlon XP 2200+, 1.5 Gb RAM
2) Gentoo 2004.1, zm 1.19.4, P4, 2.4 GHz, 500 Mb RAM
Not sure if this is a bug - but it would be handly to have the throttling work as expected - I don't really need 25 fps...and I need to add a few more cameras. I suppose I could always get a dual Opteron...!
Regards
Rupert Eve
Strange CPU Behaviour
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Strange CPU Behaviour: Update
Phil
OK - so I went and got the dual Opteron, (2 x 248, 4 Gb RAM) and I have installed 1.19.5. The shared memory segment is set to 1GB, and I am currently running one Axis 2400.
The behaviour noted is even more marked on this machine. With no max framerate set, zmc sits at about 20% of one CPU (16% usr, 0.2%sys). Setting the max frame rate to 5 fps means that cpu rises to 99% of one processor (28% usr, 23%sys). Note that the usr and sys numbers are for the box as a whole, and include X etc. Setting the framerate is clearly hitting something hard outside user space...
Happy to do testing/provide more diagnostics if that is useful. For my purposes, this machine will run 6 cameras unthrottled, which is all I need. Might be useful for somebody else though - and my power bill I suppose!
For what its worth, I can report that the installation is just fine on Gentoo x86-64. The only pain for me was getting php woking in apache, as I found out the correct sequence is:
1) update USE in /etc/make.conf to include apache2 (USE="gnome gtk -qt -kde apache2")
2) emerge mod_php (apache2 is a dependency)
3) update the options in /etc/conf.d/apache2 : (APACHE2_OPTS="-D SSL -D PHP4")
4) Add the line: LoadModule php4_module extramodules/libphp4.so to /etc/apache2/conf/apache2.conf
5) restart apache. ps -eaf | grep apache should show the correct options i.e PHP4
Regards
Rupert Eve
OK - so I went and got the dual Opteron, (2 x 248, 4 Gb RAM) and I have installed 1.19.5. The shared memory segment is set to 1GB, and I am currently running one Axis 2400.
The behaviour noted is even more marked on this machine. With no max framerate set, zmc sits at about 20% of one CPU (16% usr, 0.2%sys). Setting the max frame rate to 5 fps means that cpu rises to 99% of one processor (28% usr, 23%sys). Note that the usr and sys numbers are for the box as a whole, and include X etc. Setting the framerate is clearly hitting something hard outside user space...
Happy to do testing/provide more diagnostics if that is useful. For my purposes, this machine will run 6 cameras unthrottled, which is all I need. Might be useful for somebody else though - and my power bill I suppose!
For what its worth, I can report that the installation is just fine on Gentoo x86-64. The only pain for me was getting php woking in apache, as I found out the correct sequence is:
1) update USE in /etc/make.conf to include apache2 (USE="gnome gtk -qt -kde apache2")
2) emerge mod_php (apache2 is a dependency)
3) update the options in /etc/conf.d/apache2 : (APACHE2_OPTS="-D SSL -D PHP4")
4) Add the line: LoadModule php4_module extramodules/libphp4.so to /etc/apache2/conf/apache2.conf
5) restart apache. ps -eaf | grep apache should show the correct options i.e PHP4
Regards
Rupert Eve
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
I've done some more investigation. The Axis 2400 has two output resolutions: 352x288 and 704x576.
All of the figures I gave earlier were for 352x288 - and I have just repeated the exercise again. If I set the camera to 704x576, then the framerate throttling works as expected:
So:
704x576 unthrottled: 43%of one CPU (37% usr, 1% sys)
704x576 5 fps: 14% of one CPU (11% use, 1% sys)
352x288 unthrottled: 33% of one CPU (21% usr, 1% sys)
352x288 5 fps: 99% of one CPU (30% usr, 22% sys)
Note that the climb to 99% takes about a minute - it starts at about 10%, and adds about 5% every few seconds.
Here is a few lines of top showing the offending process!
The config is here for the large image:
valiant root # zmu -q -v -m1
Monitor 1(Garden_1)
Id : 1
Name : Garden_1
Type : Remote
Host : 192.168.1.51
Port : 80
Path : /cgi-bin/mjpg/video.cgi?resolution=704x576
Width : 704
Height : 576
Palette : 4
Colours : 3
Event Prefix : Event-
Label Format : %%s - %y/%m/%d %H:%M:%S
Label Coord : 0,0
Image Buffer Count : 100
Warmup Count : 25
Pre Event Count : 10
Post Event Count : 10
Alarm Frame Count : 1
Section Length : 600
Maximum FPS : 0.00
Reference Blend %ge : 10
Function: 3 - Motion Detection
Zones : 1
Id : 1
Label : All
Type: 1 - Active
Limits : 0,0 - 703,575
Alarm RGB : ff0000
Check Method: 3 - Blobs
Min Pixel Threshold : 25
Max Pixel Threshold : 0
Min Alarm Pixels : 12165
Max Alarm Pixels : 304128
Filter Box : 3,3
Min Filter Pixels : 12165
Max Filter Pixels : 304128
Min Blob Pixels : 8110
Max Blob Pixels : 0
Min Blobs : 1
Max Blobs : 0
valiant root #
And here for the smaller image:
valiant root # zmu -q -v -m1
Monitor 1(Garden_1)
Id : 1
Name : Garden_1
Type : Remote
Host : 192.168.1.51
Port : 80
Path : /cgi-bin/mjpg/video.cgi?resolution=352x288
Width : 352
Height : 288
Palette : 4
Colours : 3
Event Prefix : Event-
Label Format : %%s - %y/%m/%d %H:%M:%S
Label Coord : 0,0
Image Buffer Count : 100
Warmup Count : 25
Pre Event Count : 10
Post Event Count : 10
Alarm Frame Count : 1
Section Length : 600
Maximum FPS : 5.00
Reference Blend %ge : 10
Function: 3 - Motion Detection
Zones : 1
Id : 1
Label : All
Type: 1 - Active
Limits : 0,0 - 351,287
Alarm RGB : ff0000
Check Method: 3 - Blobs
Min Pixel Threshold : 25
Max Pixel Threshold : 0
Min Alarm Pixels : 3041
Max Alarm Pixels : 76032
Filter Box : 3,3
Min Filter Pixels : 3041
Max Filter Pixels : 76032
Min Blob Pixels : 2027
Max Blob Pixels : 0
Min Blobs : 1
Max Blobs : 0
valiant root #
All of the figures I gave earlier were for 352x288 - and I have just repeated the exercise again. If I set the camera to 704x576, then the framerate throttling works as expected:
So:
704x576 unthrottled: 43%of one CPU (37% usr, 1% sys)
704x576 5 fps: 14% of one CPU (11% use, 1% sys)
352x288 unthrottled: 33% of one CPU (21% usr, 1% sys)
352x288 5 fps: 99% of one CPU (30% usr, 22% sys)
Note that the climb to 99% takes about a minute - it starts at about 10%, and adds about 5% every few seconds.
Here is a few lines of top showing the offending process!
Code: Select all
top - 13:18:29 up 7 days, 21:33, 13 users, load average: 0.87, 0.62, 0.57
Tasks: 108 total, 2 running, 106 sleeping, 0 stopped, 0 zombie
Cpu(s): 29.4% us, 22.0% sy, 0.0% ni, 48.4% id, 0.1% wa, 0.0% hi, 0.1% si
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10531 apache 25 0 272m 65m 144m R 99.9 1.6 1:21.46 zmc
7427 root 14 -1 75608 54m 24m S 1.4 1.4 78:06.35 X
10539 apache 15 0 227m 32m 144m S 1.2 0.8 0:01.71 zma
valiant root # zmu -q -v -m1
Monitor 1(Garden_1)
Id : 1
Name : Garden_1
Type : Remote
Host : 192.168.1.51
Port : 80
Path : /cgi-bin/mjpg/video.cgi?resolution=704x576
Width : 704
Height : 576
Palette : 4
Colours : 3
Event Prefix : Event-
Label Format : %%s - %y/%m/%d %H:%M:%S
Label Coord : 0,0
Image Buffer Count : 100
Warmup Count : 25
Pre Event Count : 10
Post Event Count : 10
Alarm Frame Count : 1
Section Length : 600
Maximum FPS : 0.00
Reference Blend %ge : 10
Function: 3 - Motion Detection
Zones : 1
Id : 1
Label : All
Type: 1 - Active
Limits : 0,0 - 703,575
Alarm RGB : ff0000
Check Method: 3 - Blobs
Min Pixel Threshold : 25
Max Pixel Threshold : 0
Min Alarm Pixels : 12165
Max Alarm Pixels : 304128
Filter Box : 3,3
Min Filter Pixels : 12165
Max Filter Pixels : 304128
Min Blob Pixels : 8110
Max Blob Pixels : 0
Min Blobs : 1
Max Blobs : 0
valiant root #
And here for the smaller image:
valiant root # zmu -q -v -m1
Monitor 1(Garden_1)
Id : 1
Name : Garden_1
Type : Remote
Host : 192.168.1.51
Port : 80
Path : /cgi-bin/mjpg/video.cgi?resolution=352x288
Width : 352
Height : 288
Palette : 4
Colours : 3
Event Prefix : Event-
Label Format : %%s - %y/%m/%d %H:%M:%S
Label Coord : 0,0
Image Buffer Count : 100
Warmup Count : 25
Pre Event Count : 10
Post Event Count : 10
Alarm Frame Count : 1
Section Length : 600
Maximum FPS : 5.00
Reference Blend %ge : 10
Function: 3 - Motion Detection
Zones : 1
Id : 1
Label : All
Type: 1 - Active
Limits : 0,0 - 351,287
Alarm RGB : ff0000
Check Method: 3 - Blobs
Min Pixel Threshold : 25
Max Pixel Threshold : 0
Min Alarm Pixels : 3041
Max Alarm Pixels : 76032
Filter Box : 3,3
Min Filter Pixels : 3041
Max Filter Pixels : 76032
Min Blob Pixels : 2027
Max Blob Pixels : 0
Min Blobs : 1
Max Blobs : 0
valiant root #
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Ah, I think I can feel a small penny dropping. I hadn't cottoned on to the two importants parts here, (1) you are using Axis cameras with the mpjpeg feed and (2) you are limiting the capture rate. If you want to limit the frame rate for an Axis camera and aren't just doing still captures you have to do things slightly differently.
Basically you can't limit a pushed feed like that at the capturing end as unless told otherwise the Axis cam will just be firing images down the pipe as fast as it can regardless of what the capturing end thinks it's getting. So you need to either go into your Axis config and limit the rate there or change your path and add something like '&req_fps=5' to the string, which will limit the camera to sending no more than 5 frames per second down. This is for the Axis cams I have at least, it may be slightly different for the 2400, check the Axis developer pages for details. Then change the ZM monitor to have no limit on it.
This should hopefully slow things down in a controlled way. Trying to limit the rate at the client end just means that a backlog of frames builds up until it starts overflowing or causing other problems which is why I think you are seeing the CPU usage go up as zmc tries to cope with a flood of images it doesn't want but can't get rid of.
That may not be the cause of all of your troubles but it's worth giving a go to see if it helps at all.
Phil,
Basically you can't limit a pushed feed like that at the capturing end as unless told otherwise the Axis cam will just be firing images down the pipe as fast as it can regardless of what the capturing end thinks it's getting. So you need to either go into your Axis config and limit the rate there or change your path and add something like '&req_fps=5' to the string, which will limit the camera to sending no more than 5 frames per second down. This is for the Axis cams I have at least, it may be slightly different for the 2400, check the Axis developer pages for details. Then change the ZM monitor to have no limit on it.
This should hopefully slow things down in a controlled way. Trying to limit the rate at the client end just means that a backlog of frames builds up until it starts overflowing or causing other problems which is why I think you are seeing the CPU usage go up as zmc tries to cope with a flood of images it doesn't want but can't get rid of.
That may not be the cause of all of your troubles but it's worth giving a go to see if it helps at all.
Phil,
You got it...5 fps at 352x288 now looks more reasonable:
Thanks very much...
Rupert
Code: Select all
top - 22:10:18 up 9 days, 6:25, 12 users, load average: 0.04, 0.32, 0.58
Tasks: 107 total, 1 running, 106 sleeping, 0 stopped, 0 zombie
Cpu(s): 5.7% us, 0.3% sy, 0.0% ni, 94.0% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 4066340k total, 2485444k used, 1580896k free, 315672k buffers
Swap: 1959920k total, 0k used, 1959920k free, 1677680k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7427 root 14 -1 75608 54m 24m S 6.7 1.4 84:25.25 X
15603 apache 15 0 227m 32m 144m S 2.5 0.8 0:04.77 zmc
15611 apache 15 0 227m 32m 144m S 1.5 0.8 0:02.64 zma
6941 root 15 0 194m 69m 142m S 0.5 1.7 3:49.28 firefox-bin
Rupert
I was having the exact same problem with the Axis 2100 cameras. CPU usage was very high on my very minimal Duron 1500 w/512MB RAM. The machine was basically useless when Zoneminder was running.
Forcing the cameras to req_fps=5 and changing Zoneminder to grab all frames brought the per-camera cpu usage to around 15% max. I'm able to run 4 cameras off this minimal server at a total of 60% for 4 cameras, and it works great!
This might be a good addition to the FAQ for Axis camera users or any cameras that stream video.
Forcing the cameras to req_fps=5 and changing Zoneminder to grab all frames brought the per-camera cpu usage to around 15% max. I'm able to run 4 cameras off this minimal server at a total of 60% for 4 cameras, and it works great!
This might be a good addition to the FAQ for Axis camera users or any cameras that stream video.