Part A – installing ZoneMinder from Ubuntu repositories:
- 
- Install libavcodec with extra codecs (for x264 support)
- Install ZoneMinder 1.24.2 from the Ubuntu repositories
- Correct the Apache2 configurations necessary for ZoneMinder
- Fix ZoneMinder startup issue
- Show the current kernel.shmall and kernel.shmmax values and adjust them to 90% of the system memory
 - STREAM_METHOD = mpeg
- MPEG_LIVE_FORMAT = asf
 
 - #!/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
 fiecho “— Installing extra codecs, which includes x264 support…” 
 apt-get -y install libavcodec-extra-52 libavformat-extra-52 libswscale-extra-0 libavfilter-extra-1echo “— Installing ZoneMinder…” 
 apt-get -y install zoneminderecho “— Adding ZoneMinder to Apache2…” 
 ln -s /etc/zm/apache.conf /etc/apache2/sites-available/zoneminder.conf
 a2ensite zoneminder
 service apache2 restartecho “— 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 92echo “— 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 restartecho “— 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.”
 
I have written a shell script to:Here’s the script:
Code:
You might want to make the following changes under Options > Images:
Also read through the http://www.zoneminder.com/wiki/index.ph … peg%2C_etc.) guide, and you might want to follow the “Add the video group to the www-data user” and “Fix deprecated usage of ereg() in functions.php” steps.
I have tested this by altering FFMPEG_OUTPUT_OPTIONS and I’ve successfully managed to let ZoneMinder convert the recorded event into a x264 encoded video using ffmpeg’s x264 medium + main presets.
Just remember that if you want to test the input of x264 streams, you have to select ffmpeg as the source type AND if you’re streaming from a local file, ensure that the www-user has read permissions!
This entry was posted in Uncategorized. Bookmark the permalink.