Problems changing resolution

Forum for questions and support relating to the 1.24.x releases only.
Locked
pp1981
Posts: 17
Joined: Sun Jul 10, 2011 3:29 pm

Problems changing resolution

Post by pp1981 »

Hello,
I have some IPcam FOSCAM FI8918W and FI8905W.
I've got installed ZM in traditional mode (with "Package manger" I think - in italian is "Gestore pacchetti") and I install correctly all the IPcam in ZM.
I found some problems when I change the resolution of my IPcam from its URL: for example I change it from 320x240 in 640x480 but writing in the source/source both 320x240 and 640x480 I can't view anything.
With another computer on which I installed ZM with the following script I haven't that problem. In particular the various situation I notice are indicated below the script...
#!/bin/sh
# ZoneMinder 1.24.2 installation script
#
# Copyright (C) 2010 Chris "Pada" Kistner
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.

echo "--- Checking for root privileges..."
if [ "`whoami`" != "root" ]; then
echo Error: This script requires root access
exit 1
fi

echo "--- Installing extra codecs, which includes x264 support..."
apt-get -y install libavcodec-extra-52 libavformat-extra-52 libswscale-extra-0 libavfilter-extra-1

echo "--- Installing ZoneMinder..."
apt-get -y install zoneminder

echo "--- Adding ZoneMinder to Apache2..."
ln -s /etc/zm/apache.conf /etc/apache2/sites-available/zoneminder.conf
a2ensite zoneminder
service apache2 restart

echo "--- Adding alias for zoneminder service and fixing ZoneMinder startup..."
ln -s /etc/init.d/zoneminder /etc/init.d/zm
update-rc.d -f zoneminder remove
update-rc.d -f zm remove
update-rc.d zm defaults 92

echo "--- Applying ZMFix, adding www-data user to video group and restarting ZM..."
chmod 4755 /usr/bin/zmfix
zmfix -a
adduser www-data video
service zm restart

echo "--- Correcting SHM to 90% of memory..."
apt-get -y install coreutils bc
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"
if [ "$shmmax" -eq "$shmmax_cur" ] && [ "$shmall" -eq "$shmall_cur" ]; then
echo "-- Recommended shm values already set"
else
echo "-- Recommended: kernel.shmmax = $shmmax B = $shmmax_mb MB"
echo "-- Recommended: kernel.shmmall = $shmall pages"
file=/etc/sysctl.conf
if [ "`grep "^kernel\.shmmax" $file -c`" != "0" ]; then
echo "-- Replacing: kernel.shmmax in $file"
sed "s/^kernel\.shmmax.*$/kernel.shmmax=$shmmax/g" -i $file
else
echo "-- Adding: kernel.shmmax to $file"
echo kernel.shmmax=$shmmax >> $file
fi
if [ "`grep "^kernel\.shmall" /etc/sysctl.conf -c`" != "0" ]; then
echo "-- Replacing: kernel.shmall in $file"
sed "s/^kernel\.shmall.*$/kernel.shmall=$shmall/g" -i $file
else
echo "-- Adding: kernel.shmall to $file"
echo kernel.shmall=$shmall >> $file
fi
echo "-- Using: new sysctl values"
sysctl -p
fi

# Done
echo "--- Done."

These are the situation I notify:


With traditional intallation:
IPcam......Source/source....Source color....Streaming........Event
320x240...320x240.............green..............OK..................OK
320x240...640x480.............red.................none................none
640x480...320x240.............red.................black screen.....OK
640x480...640x480.............red.................none................none



With script:
IPcam......Source/source....Source color....Streaming........Event
320x240...320x240.............green..............OK..................OK
320x240...640x480.............red.................black screen.....OK (with resolution 320x240 but dimension 640x480)
640x480...320x240.............red.................black screen.....OK
640x480...640x480.............green.............OK...................OK (with resolution 320x240 but dimension 640x480)

I don't know if the different behavior is caused by the script but I think that the only one difference in the installation is that.

Any idea to solve that problem???

Thank you
pp1981
bb99
Posts: 943
Joined: Wed Apr 02, 2008 12:04 am

Re: Problems changing resolution

Post by bb99 »

The resolution of the camera output and the resolution on the source tab must match exactly or problems occur. The script is changing the value of shmmax which will allow the higher resolutions such as 640*480.
pp1981
Posts: 17
Joined: Sun Jul 10, 2011 3:29 pm

Re: Problems changing resolution

Post by pp1981 »

OK...

For anyone that have this problem I think it is solvable with the process explained here at the paragraps: "What does a 'Can't shmget: Invalid argument' error in my logs mean? and my cameras won't display video at higher resolutions."

http://www.zoneminder.com/wiki/index.php/FAQ

Is it right bb99 ???

Thank you
bb99
Posts: 943
Joined: Wed Apr 02, 2008 12:04 am

Re: Problems changing resolution

Post by bb99 »

You got it exactly. Used to be very common, newer versions build using mmap so this will become mute.
pp1981
Posts: 17
Joined: Sun Jul 10, 2011 3:29 pm

Re: Problems changing resolution

Post by pp1981 »

Now I'm only reading that page: sincerly I thought that it is easier to understand.

How can I know if my ZM is built with mmap or with /dev/shm shared memory device?

Have you got a method more understandable to change the shmmax?
Now I've only 1 GB but I want to increase it.
Is it a problem?

Thanks
bb99
Posts: 943
Joined: Wed Apr 02, 2008 12:04 am

Re: Problems changing resolution

Post by bb99 »

In a terminal type Ipcs -m, the output should give you a clue as to whether or not ZM is using shared. Easy way to allocate shared is to edit /etc/sysctl.conf; I usually recommend raising by 150 to 200% of the default value to start with.
Increasing physical memory shouldn't be an issue.
pp1981
Posts: 17
Joined: Sun Jul 10, 2011 3:29 pm

Re: Problems changing resolution

Post by pp1981 »

Perfect: I changed that like you described.

Thank you

Good luck
Locked