[SOLVED] ZM does not show hi-res version of new camera

Forum for questions and support relating to the 1.28.x releases only.
Locked
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

[SOLVED] ZM does not show hi-res version of new camera

Post by asker »

Hi folks, I've been using ZM 1.28.1 with Ubuntu 14.04 pretty well with two Foscam I9831Ws (1280x960). Let's call them A&B

I setup 2 more of the exact same cameras (lets call them C&D) . The problem I am facing is when I am adding the new monitors, and specify the capture details as 1280x960 with color depth either 32 or 24, ZM does not render the new cameras

The error I get is:
'zma -m 8' exited abnormally, exit status 255

But if I change resolution to 760x480 and depth of 24, it works just fine.

The odd part is it happily records 1280x960 for the previous 2. They are the _same_ cameras, same HW and firmware

My load is consistently 0.88

My settings for my HD cameras (all of them)

Source Type: FFMPEG
Function: Nodect
Max FPS: 5
Source: rtsp://user:pwd@ip:port/videoMain
Remote Method: RTP/RTSP
Target Color Space: 32 bit (changed to 24 bit for new ones)
Capture Width: 1280 (changed to 720 for new ones)
Capture Height: 960 (changed to 480 for new ones)

I tried using VLC with the rtsp url with the new cameras and it works just fine

Any help?
Last edited by asker on Fri Mar 13, 2015 6:51 pm, edited 1 time in total.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Going bonkers: ZM does not show hi-res version of new ca

Post by asker »

Some more debugging information - zmc is coredumping
When I ran it from command line with the new 1280x960 camera set to this mode:
root@camerapc:/home/user# zmc -m 7
Bus error (core dumped)
weblog:

Code: Select all

DATE/TIME
COMPONENT	PID	LEVEL	MESSAGE	FILE	LINE
2015-03-07 07:36:32.053920	zmdc	17374	INF	'zmc -m 7' crashed, signal 134	zmdc.pl	
2015-03-07 07:36:31.322880	zmdc	17374	ERR	'zma -m 7' exited abnormally, exit status 255	zmdc.pl	
2015-03-07 07:36:31.238230	zmdc	17625	INF	'zmc -m 7' started at 15/03/07 07:36:31	zmdc.pl	
2015-03-07 07:36:31.237140	zmdc	17374	INF	'zmc -m 7' starting at 15/03/07 07:36:31, pid = 17625	zmdc.pl	
2015-03-07 07:36:31.225325	zma_m7	17623	ERR	Shared data not initialised by capture daemon for monitor garage	zm_monitor.cpp	421
2015-03-07 07:36:31.143820	zmdc	17374	INF	Starting pending process, zmc -m 7	zmdc.pl	
2015-03-07 07:36:31.102110	zmdc	17623	INF	'zma -m 7' started at 15/03/07 07:36:31	zmdc.pl	
2015-03-07 07:36:31.102090	zmdc	17374	INF	'zma -m 7' starting at 15/03/07 07:36:31, pid = 17623	zmdc.pl	
2015-03-07 07:36:31.052380	zmdc	17374	INF	Starting pending process, zma -m 7	zmdc.pl	
2015-03-07 07:36:21.772640	zmdc	17374	INF	'zmc -m 7' crashed, signal 134	zmdc.pl	
2015-03-07 07:36:21.317890	zmdc	17374	ERR	'zma -m 7' exited abnormally, exit status 255	zmdc.pl	
2015-03-07 07:36:21.240280	zmdc	17606	INF	'zmc -m 7' started at 15/03/07 07:36:21	zmdc.pl	
2015-03-07 07:36:21.237700	zmdc	17374	INF	'zmc -m 7' starting at 15/03/07 07:36:21, pid = 17606	zmdc.pl
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Going bonkers: ZM does not show hi-res version of new ca

Post by asker »

Okay, this is most certainly a memory issue, but I'm not sure how to fix it. I think I've allocated sufficient memory.

This is my current setting for my 2GB RAM machine:

ZM has a script that runs that recommends ideal size (90% of av. mem) - I copied that part and ran it to make sure and set my sysctl accordingly:

-- Total memory = 1833811968 B = 1748 MB
-- Page size = 4096 B
-- Current kernel.shmmax = 1650430771 B = 1573 MB
-- Current kernel.shmall = 447708 pages
-- Recommended: kernel.shmmax = 1650430771 B = 1573 MB
-- Recommended: kernel.shmmall = 447708 pages

I have a total of 5 cameras, I'd like to set it up to capture 1280x960 @ 32b or @24 bit depth. I've set FPS to 5 for each.

The script I ran:

root@camerapc:/home/user# cat shm.sh

Code: Select all

#!/bin/bash
page_size=$(getconf PAGE_SIZE)
mem_bytes=$(awk '/MemTotal:/ { printf "%0.f",$2 * 1024}' /proc/meminfo)
mb=1048576
mem_bytes_mb=$(expr $mem_bytes / $mb)
shmmax=$(echo "$mem_bytes * 0.90" | bc | cut -f 1 -d '.')
shmmax_mb=$(expr $shmmax / $mb)
shmall=$(expr $mem_bytes / $page_size)
shmmax_cur=$(sysctl -n kernel.shmmax)
shmmax_cur_mb=$(expr $shmmax_cur / $mb)
shmall_cur=$(sysctl -n kernel.shmall)
echo "-- Total memory = $mem_bytes B = $mem_bytes_mb MB"
echo "-- Page size = $page_size B"
echo "-- Current kernel.shmmax = $shmmax_cur B = $shmmax_cur_mb MB"
echo "-- Current kernel.shmall = $shmall_cur pages"
echo "-- Recommended: kernel.shmmax = $shmmax B = $shmmax_mb MB"
echo "-- Recommended: kernel.shmmall = $shmall pages"
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Going bonkers: ZM does not show hi-res version of new ca

Post by asker »

Okay, I was running out of shared memory allocations. I've tuned the system and things are back to normal.

I'm a little confused with what I missed in the math.

What I did was this:

Code: Select all

1.2 * ((1280*960*50*24*4/8/1024/1024 )  + (640 *480  * 24*50/8 /1024/1024))
4 cameras @ 1280* 960 @ 24bit color, Image buffer = 50
1 camera @ 640*480 @ 24 bit color, Image buffer = 50
Add 20% overheads

=900MB approx

So how am I running out of memory? I know I have other processes running.

Here is my top output after setting two of them to 1280x960 @ 24bp, two to 720x480 @ 24bp and the low res one to 640x480. This is the max I can go. If I try and change another of the 720x480 to 1280x960, I get core dumps from zmc

Code: Select all

top - 08:38:35 up 35 min,  1 user,  load average: 0.75, 0.98, 0.95
Tasks: 174 total,   5 running, 169 sleeping,   0 stopped,   0 zombie
%Cpu(s): 27.0 us,  1.3 sy,  0.0 ni, 71.5 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem:   1790832 total,  1710420 used,    80412 free,    50244 buffers
KiB Swap:  1833980 total,      636 used,  1833344 free.  1036484 cached Mem
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Going bonkers: ZM does not show hi-res version of new ca

Post by knight-of-ni »

2GB simply isn't enough to do what you are doing with high resolution HD cameras.
I almost said something in your previous thread, but decided not to since you hadn't reported a problem.

Zoneminder uses mmap, which maps to tmpfs on modern distros, which points to the files sytem on /dev/shm, which sits in your ram.

A couple of things to note about this:
- tmpfs will dynamically expand up to 50% of your physical ram. This can be adjusted in your fstab
- Normal methods for checking memory aren't going to be helpful because we are dealing with a file system. For example, if you had 500GB free on your hard disk, and you tried to write a 1TB file to the disk, would you ever see your filesystem report less than 500GB, free? Answer = No, because the too-large file never completes in the first place. The same thing is happening here. Zoneminder is trying to write a file (e.g. mmap a file) to your ramdisk, but the ramdisk runs out space to grow. Any tools you use to report free memory aren't going to report a low memory condition.

The best thing you can do to resolve this situation is to add more memory. The system would run well with 4GB of RAM, but adding even more would help your mysql performance as noted in your previous thread.

If you don't want to or otherwise can't add more memory, then you have to make some compromises:
- bump up the limit of tmpfs in fstab (this will leave less free memory for other applications)
- reduce the image resolution
- reduce the color depth to 8bit grayscale
- I forget, are you running a desktop? If you are, rebuilding with the “server” version of your distro will save quite a bit of memory.

Even if you get the system working with compromises, you are rather close to the limits of your hardware.... anything that causes a resource spike could easily cause things to crash or become
unstable.
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/
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Going bonkers: ZM does not show hi-res version of new ca

Post by knight-of-ni »

Followup - if you really are building zoneminder with shared memory, rather than mapped memory (you have to manually specify this at build), then the same rules apply... only the mechanism by which memory is used has changed.
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/
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Going bonkers: ZM does not show hi-res version of new ca

Post by asker »

*bingo*. knnniggett you rock.

As it turns out ZM is using tmpfs and I was at 98% space for tmpfs (set at 50%). I've changed it to 70% and tested recording at 1280x960 and they all work, and tmpfs is at 85%.

I'd be happy to add more RAM, but I wanted to figure out where I was going wrong --> and you pointed me to the right place. Whee!

And as it turns out, shm usage spikes when ZM launches other processes etc - so even at 80% at times it goes up to 100% and then everything becomes red if I bump them all to 1280x960. So till I add more RAM, I've kept them all at 720x480 @ 24 (with the low res one at 640x480 @ 8bgrey)
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: [SOLVED] ZM does not show hi-res version of new camera

Post by asker »

Quick update: Upgraded to 4GB (from 2GB)
Works great at full res.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Locked