{"id":145,"date":"2011-03-31T03:28:54","date_gmt":"2011-03-31T03:28:54","guid":{"rendered":"http:\/\/xbmc\/wordpress\/?p=145"},"modified":"2011-08-14T11:30:48","modified_gmt":"2011-08-14T16:30:48","slug":"zoneminder-ubuntu-10-10-setup","status":"publish","type":"post","link":"https:\/\/xfloyd.net\/blog\/?p=145","title":{"rendered":"ZoneMinder Ubuntu 10.10 Setup"},"content":{"rendered":"<p><strong>Part A &#8211; installing ZoneMinder from Ubuntu repositories:<\/strong><\/p>\n<ul>\n<ul>\n<li>\n<ol>\n<li>Install libavcodec with extra codecs (for x264 support)<\/li>\n<li>Install ZoneMinder 1.24.2 from the Ubuntu repositories<\/li>\n<li>Correct the Apache2 configurations necessary for ZoneMinder<\/li>\n<li>Fix ZoneMinder startup issue<\/li>\n<li>Show the current kernel.shmall and kernel.shmmax values and adjust them to 90% of the system memory<\/li>\n<\/ol>\n<ul>\n<li>STREAM_METHOD = mpeg<\/li>\n<li>MPEG_LIVE_FORMAT = asf<!--more--><\/li>\n<\/ul>\n<hr \/>\n<ul>\n<ul>#!\/bin\/sh<\/ul>\n<\/ul>\n<ul>\n<ul># ZoneMinder 1.24.2 installation script<\/ul>\n<\/ul>\n<ul>\n<ul>#<\/ul>\n<\/ul>\n<ul>\n<ul># Copyright (C) 2010 Chris &#8220;Pada&#8221; Kistner<\/ul>\n<\/ul>\n<ul>\n<ul>#<\/ul>\n<\/ul>\n<ul>\n<ul># This program is free software; you can redistribute it and\/or<\/ul>\n<\/ul>\n<ul>\n<ul># modify it under the terms of the GNU General Public License<\/ul>\n<\/ul>\n<ul>\n<ul># as published by the Free Software Foundation; either version 2<\/ul>\n<\/ul>\n<ul>\n<ul># of the License, or (at your option) any later version.<\/ul>\n<\/ul>\n<p>echo &#8220;&#8212; Checking for root privileges&#8230;&#8221;<br \/>\nif [ &#8220;`whoami`&#8221; != &#8220;root&#8221; ]; then<br \/>\necho Error: This script requires root access<br \/>\nexit 1<br \/>\nfi<\/p>\n<p>echo &#8220;&#8212; Installing extra codecs, which includes x264 support&#8230;&#8221;<br \/>\napt-get -y install libavcodec-extra-52 libavformat-extra-52 libswscale-extra-0 libavfilter-extra-1<\/p>\n<p>echo &#8220;&#8212; Installing ZoneMinder&#8230;&#8221;<br \/>\napt-get -y install zoneminder<\/p>\n<p>echo &#8220;&#8212; Adding ZoneMinder to Apache2&#8230;&#8221;<br \/>\nln -s \/etc\/zm\/apache.conf \/etc\/apache2\/sites-available\/zoneminder.conf<br \/>\na2ensite zoneminder<br \/>\nservice apache2 restart<\/p>\n<p>echo &#8220;&#8212; Adding alias for zoneminder service and fixing ZoneMinder startup&#8230;&#8221;<br \/>\nln -s \/etc\/init.d\/zoneminder \/etc\/init.d\/zm<br \/>\nupdate-rc.d -f zoneminder remove<br \/>\nupdate-rc.d -f zm remove<br \/>\nupdate-rc.d zm defaults 92<\/p>\n<p>echo &#8220;&#8212; Applying ZMFix, adding www-data user to video group and restarting ZM&#8230;&#8221;<br \/>\nchmod 4755 \/usr\/bin\/zmfix<br \/>\nzmfix -a<br \/>\nadduser www-data video<br \/>\nservice zm restart<\/p>\n<p>echo &#8220;&#8212; Correcting SHM to 90% of memory&#8230;&#8221;<br \/>\napt-get -y install coreutils bc<br \/>\npage_size=$(getconf PAGE_SIZE)<br \/>\nmem_bytes=$(awk &#8216;\/MemTotal:\/ { printf &#8220;%0.f&#8221;,$2 * 1024}&#8217; \/proc\/meminfo)<br \/>\nmb=1048576<br \/>\nmem_bytes_mb=$(expr $mem_bytes \/ $mb)<br \/>\nshmmax=$(echo &#8220;$mem_bytes * 0.90&#8221; | bc | cut -f 1 -d &#8216;.&#8217;)<br \/>\nshmmax_mb=$(expr $shmmax \/ $mb)<br \/>\nshmall=$(expr $mem_bytes \/ $page_size)<br \/>\nshmmax_cur=$(sysctl -n kernel.shmmax)<br \/>\nshmmax_cur_mb=$(expr $shmmax_cur \/ $mb)<br \/>\nshmall_cur=$(sysctl -n kernel.shmall)<br \/>\necho &#8220;&#8211; Total memory = $mem_bytes B = $mem_bytes_mb MB&#8221;<br \/>\necho &#8220;&#8211; Page size = $page_size B&#8221;<br \/>\necho &#8220;&#8211; Current kernel.shmmax = $shmmax_cur B = $shmmax_cur_mb MB&#8221;<br \/>\necho &#8220;&#8211; Current kernel.shmall = $shmall_cur pages&#8221;<br \/>\nif [ &#8220;$shmmax&#8221; -eq &#8220;$shmmax_cur&#8221; ] &amp;&amp; [ &#8220;$shmall&#8221; -eq &#8220;$shmall_cur&#8221; ]; then<br \/>\necho &#8220;&#8211; Recommended shm values already set&#8221;<br \/>\nelse<br \/>\necho &#8220;&#8211; Recommended: kernel.shmmax = $shmmax B = $shmmax_mb MB&#8221;<br \/>\necho &#8220;&#8211; Recommended: kernel.shmmall = $shmall pages&#8221;<br \/>\nfile=\/etc\/sysctl.conf<br \/>\nif [ &#8220;`grep &#8220;^kernel.shmmax&#8221; $file -c`&#8221; != &#8220;0&#8221; ]; then<br \/>\necho &#8220;&#8211; Replacing: kernel.shmmax in $file&#8221;<br \/>\nsed &#8220;s\/^kernel.shmmax.*$\/kernel.shmmax=$shmmax\/g&#8221; -i $file<br \/>\nelse<br \/>\necho &#8220;&#8211; Adding: kernel.shmmax to $file&#8221;<br \/>\necho kernel.shmmax=$shmmax &gt;&gt; $file<br \/>\nfi<br \/>\nif [ &#8220;`grep &#8220;^kernel.shmall&#8221; \/etc\/sysctl.conf -c`&#8221; != &#8220;0&#8221; ]; then<br \/>\necho &#8220;&#8211; Replacing: kernel.shmall in $file&#8221;<br \/>\nsed &#8220;s\/^kernel.shmall.*$\/kernel.shmall=$shmall\/g&#8221; -i $file<br \/>\nelse<br \/>\necho &#8220;&#8211; Adding: kernel.shmall to $file&#8221;<br \/>\necho kernel.shmall=$shmall &gt;&gt; $file<br \/>\nfi<br \/>\necho &#8220;&#8211; Using: new sysctl values&#8221;<br \/>\nsysctl -p<br \/>\nfi<\/p>\n<p># Done<br \/>\necho &#8220;&#8212; Done.&#8221;<\/p>\n<hr \/>\n<\/li>\n<\/ul>\n<\/ul>\n<p>I have written a shell script to:Here&#8217;s the script:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<p>You might want to make the following changes under Options &gt; Images:<br \/>\nAlso read through the <a href=\"http:\/\/www.zoneminder.com\/wiki\/index.php\/Ubuntu_10.04_Server_64-bit_%28with_ffmpeg%2C_etc\">http:\/\/www.zoneminder.com\/wiki\/index.ph &#8230; peg%2C_etc<\/a>.) guide, and you might want to follow the &#8220;Add the video group to the www-data user&#8221; and &#8220;Fix deprecated usage of ereg() in functions.php&#8221; steps.<\/p>\n<p>I have tested this by altering FFMPEG_OUTPUT_OPTIONS and I&#8217;ve successfully managed to let ZoneMinder convert the recorded event into a x264 encoded video using ffmpeg&#8217;s x264 medium + main presets.<\/p>\n<p>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&#8217;re streaming from a local file, ensure that the www-user has read permissions!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part A &#8211; 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 = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/145"}],"collection":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=145"}],"version-history":[{"count":2,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions"}],"predecessor-version":[{"id":402,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions\/402"}],"wp:attachment":[{"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}