From fe3f3d91ceaba2dbcb4fb6a1523d2c925cc5760d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 16 Dec 2016 09:12:27 -0500 Subject: [PATCH 1/9] replace the old socket_sendto error message with something more useful so that people stop asking us how to fix it. --- web/ajax/stream.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/ajax/stream.php b/web/ajax/stream.php index 5e9798011..da6c0133e 100644 --- a/web/ajax/stream.php +++ b/web/ajax/stream.php @@ -47,12 +47,16 @@ switch ( $_REQUEST['command'] ) $remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'s.sock'; $max_socket_tries = 10; -while ( !file_exists($remSockFile) && $max_socket_tries-- ) //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second. - usleep(200000); +while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second. + usleep(200000); +} -if ( !@socket_sendto( $socket, $msg, strlen($msg), 0, $remSockFile ) ) -{ +if ( !file_exists($remSockFile) ) { + ajaxError("Socket $ramSocketFile does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache (sudo a2enmod CGI) and check that the PATH_ZMS is set correctly (typically /zm/cgi-bin/nph-zms). Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit."); +} else { + if ( !@socket_sendto( $socket, $msg, strlen($msg), 0, $remSockFile ) ) { ajaxError( "socket_sendto( $remSockFile ) failed: ".socket_strerror(socket_last_error()) ); + } } $rSockets = array( $socket ); From 8b726996f755d6b46bb3016600747764632196b2 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 19 Dec 2016 21:36:39 -0500 Subject: [PATCH 2/9] FAQ fixes, more text about zms problems in it, and adjust the socket_sendto error message to point to the FAQ entry that is relevant. --- docs/faq.rst | 10 +++++++--- web/ajax/stream.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index cfa2da302..20591ddbf 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -8,7 +8,7 @@ How can I stop ZoneMinder filling up my disk? --------------------------------------------- Recent versions of ZoneMinder come with a filter you can use for this purpose already included. -The filter is called **PurgeWhenFull** and to find it, choose one of the event counts from the console page, for instance events in the last hour, for one of your monitors. **Note** that this filter is automatically enabled if you do a frresh install of ZoneMinder including creating a new Database. If you already have an existing Database and are upgrading Zoneminder, it will retain the settings of the filter (which in earlier releases was disabled by default). So you may want to check if PurgeWhenFull is enabled and if not, enable it. +The filter is called **PurgeWhenFull** and to find it, choose one of the event counts from the console page, for instance events in the last hour, for one of your monitors. **Note** that this filter is automatically enabled if you do a fresh install of ZoneMinder including creating a new database. If you already have an existing database and are upgrading ZoneMinder, it will retain the settings of the filter (which in earlier releases was disabled by default). So you may want to check if PurgeWhenFull is enabled and if not, enable it. To enable it, go to Web Console, click on any of your Events of any of your monitors. This will bring up an event listing and a filter window. @@ -36,7 +36,7 @@ There are two methods for ZM to remove files when they are deleted that can be f ZM_OPT_FAST_DELETE: -Normally an event created as the result of an alarm consists of entries in one or more database tables plus the various files associated with it. When deleting events in the browser it can take a long time to remove all of this if your are trying to do a lot of events at once. It is recommended that you set this option which means that the browser client only deletes the key entries in the events table, which means the events will no longer appear in the listing, and leaves the zmaudit daemon to clear up the rest later. +Normally an event created as the result of an alarm consists of entries in one or more database tables plus the various files associated with it. When deleting events in the browser it can take a long time to remove all of this if your are trying to do a lot of events at once. It is recommended that you set this option which means that the browser client only deletes the key entries in the events table, which means the events will no longer appear in the listing, and leaves the zmaudit daemon to clear up the rest later. @@ -257,7 +257,7 @@ Why can't I see streamed images when I can see stills in the Zone window etc? This issue is normally down to one of two causes -1) You are using Internet Explorer and are trying to view multi-part jpeg streams. IE does not support these streams directly, unlike most other browsers. You will need to install Cambozola or another multi-part jpeg aware pluging to view them. To do this you will need to obtain the applet from the Downloads page and install the cambozola.jar file in the same directly as the ZoneMinder php files. Then find the ZoneMinder Options->Images page and enable ZM_OPT_CAMBOZOLA and enter the web path to the .jar file in ZM_PATH_CAMBOZOLA. This will ordinarily just be cambozola.jar. Provided (Options / B/W tabs) WEB_H_CAN_STREAM is set to auto and WEB_H_STREAM_METHOD is set to jpeg then Cambozola should be loaded next time you try and view a stream. +1) You are using Internet Explorer and are trying to view multi-part jpeg streams. IE does not support these streams directly, unlike most other browsers. You will need to install Cambozola or another multi-part jpeg aware pluging to view them. To do this you will need to obtain the applet from the Downloads page and install the cambozola.jar file in the same directory as the ZoneMinder php files. Then find the ZoneMinder Options->Images page and enable ZM_OPT_CAMBOZOLA and enter the web path to the .jar file in ZM_PATH_CAMBOZOLA. This will ordinarily just be cambozola.jar. Provided (Options / B/W tabs) WEB_H_CAN_STREAM is set to auto and WEB_H_STREAM_METHOD is set to jpeg then Cambozola should be loaded next time you try and view a stream. '''NOTE''': If you find that the Cambozola applet loads in IE but the applet just displays the version # of Cambozola and the author's name (as opposed to seeing the streaming images), you may need to chmod (''-rwxrwxr-x'') your (''usr/share/zoneminder/'') cambozola.jar: @@ -269,6 +269,10 @@ Once I did this, images started to stream for me. 2) The other common cause for being unable to view streams is that you have installed the ZoneMinder cgi binaries (zms and nph-zms) in a different directory than your web server is expecting. Make sure that the --with-cgidir option you use to the ZoneMinder configure script is the same as the CGI directory configure for your web server. If you are using Apache, which is the most common one, then in your httpd.conf file there should be a line like ``ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"`` where the last directory in the quotes is the one you have specified. If not then change one or the other to match. Be warned that configuring apache can be complex so changing the one passed to the ZoneMinder configure (and then rebuilding and reinstalling) is recommended in the first instance. If you change the apache config you will need to restart apache for the changes to take effect. If you still cannot see stream reliably then try changing Options->Paths->ZM_PATH_ZMS to just use zms if nph-zms is specified, or vice versa. Also check in your apache error logs. +Also, please check the value of the ZM_PATH_ZMS setting under the Paths Options tab. It is where you configure the URL to the zms or nph-zms CGI executable. Under most Debian-based distros this value should be /zm/cgi-bin/nph-zms but in the past may have been /cgi-bin/nph-zms or you may have configured it to be something else. + +Lastly, please look for errors created by the zmc processes. If zmc isn't running, then zms will not be able to get an image from it and will exit. + I have several monitors configured but when I load the Montage view in FireFox why can I only see two? or, Why don't all my cameras display when I use the Montage view in FireFox? -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/web/ajax/stream.php b/web/ajax/stream.php index da6c0133e..f862cfaf9 100644 --- a/web/ajax/stream.php +++ b/web/ajax/stream.php @@ -52,7 +52,7 @@ while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are } if ( !file_exists($remSockFile) ) { - ajaxError("Socket $ramSocketFile does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache (sudo a2enmod CGI) and check that the PATH_ZMS is set correctly (typically /zm/cgi-bin/nph-zms). Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit."); + ajaxError("Socket $ramSocketFile does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. Please go to http://zoneminder.readthedocs.io/en/latest/faq.html#why-can-t-i-see-streamed-images-when-i-can-see-stills-in-the-zone-window-etc for more information."); } else { if ( !@socket_sendto( $socket, $msg, strlen($msg), 0, $remSockFile ) ) { ajaxError( "socket_sendto( $remSockFile ) failed: ".socket_strerror(socket_last_error()) ); From 4e892981832d4108819c4e0c77b4c195f36eaa60 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 19 Dec 2016 22:01:45 -0500 Subject: [PATCH 3/9] fix another typo and stop recommending that people use ZM_OPT_FAST_DELETE --- docs/faq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.rst b/docs/faq.rst index 20591ddbf..857012a17 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -36,7 +36,7 @@ There are two methods for ZM to remove files when they are deleted that can be f ZM_OPT_FAST_DELETE: -Normally an event created as the result of an alarm consists of entries in one or more database tables plus the various files associated with it. When deleting events in the browser it can take a long time to remove all of this if your are trying to do a lot of events at once. It is recommended that you set this option which means that the browser client only deletes the key entries in the events table, which means the events will no longer appear in the listing, and leaves the zmaudit daemon to clear up the rest later. +Normally an event created as the result of an alarm consists of entries in one or more database tables plus the various files associated with it. When deleting events in the browser it can take a long time to remove all of this if you are trying to do a lot of events at once. If you are running on an older or under-powered system, you may want to set this option which means that the browser client only deletes the key entries in the events table, which means the events will no longer appear in the listing, and leaves the zmaudit daemon to clear up the rest later. If you do so, disk space will not be freed immediately so you will need to run zmaudit more frequently. On modern systems, we recommend that you leave this off. From 09937e87f73fb43daa45eefc1da428701f2cfdef Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Tue, 20 Dec 2016 08:16:10 -0600 Subject: [PATCH 4/9] mention 32 bit color depth and make it preferred --- docs/userguide/definemonitor.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/userguide/definemonitor.rst b/docs/userguide/definemonitor.rst index c7c13d5a3..7ecd0c922 100644 --- a/docs/userguide/definemonitor.rst +++ b/docs/userguide/definemonitor.rst @@ -97,7 +97,7 @@ Device Path/Channel Device Format Enter the video format of the video stream. This is defined in various system files (e.g. /usr/include/linux/videodev.h) but the two most common are 0 for PAL and 1 for NTSC. Capture Palette - Finally for the video part of the configuration enter the colour depth. ZoneMinder supports a handful of the most common palettes, so choose one here. If in doubt try grey first, and then 24 bit colour. If neither of these work very well then YUV420P or one of the others probably will. There is a slight performance penalty when using palettes other than grey or 24 bit colour as an internal conversion is involved. These other formats are intended to be supported natively in a future version but for now if you have the choice choose one of grey or 24 bit colour. + Finally for the video part of the configuration enter the colour depth. ZoneMinder supports a handful of the most common palettes, so choose one here. If in doubt try 32 bit colour first, then 24 bit colour, then grey. If none of these work very well, and your camera is local, then YUV420P or one of the others probably will. There is a slight performance penalty when using palettes other than 32, 24, or grey palettes as an internal conversion is involved. Recent versions of ZoneMinder support 32bit colour. This capture palette provides a performance boost when used on all modern Intel-based processors. Capture Width/Height The dimensions of the video stream your camera will supply. If your camera supports several just enter the one you'll want to use for this application, you can always change it later. However I would recommend starting with no larger than 320x240 or 384x288 and then perhaps increasing and seeing how performance is affected. This size should be adequate in most cases. Some cameras are quite choosy about the sizes you can use here so unusual sizes such as 197x333 should be avoided initially. Keep aspect ratio @@ -109,7 +109,7 @@ Remote ^^^^^^ Remote Host/Port/Path - Use these fields to enter the full URL of the camera. Basically if your camera is at http://camserver.home.net:8192/cameras/camera1.jpg then these fields will be camserver.home.net, 8192 and /cameras/camera1.jpg respectively. Leave the port at 80 if there is no special port required. If you require authentication to access your camera then add this onto the host name in the form :@.com. This will usually be 24 bit colour even if the image looks black and white. Look in Supported Hardware > Network Cameras section, how to obtain these strings that may apply to your camera. + Use these fields to enter the full URL of the camera. Basically if your camera is at http://camserver.home.net:8192/cameras/camera1.jpg then these fields will be camserver.home.net, 8192 and /cameras/camera1.jpg respectively. Leave the port at 80 if there is no special port required. If you require authentication to access your camera then add this onto the host name in the form :@.com. This will usually be 32 or 24 bit colour even if the image looks black and white. Look in Supported Hardware > Network Cameras section, how to obtain these strings that may apply to your camera. Remote Image Colours Specify the amount of colours in the captured image. Unlike with local cameras changing this has no controlling effect on the remote camera itself so ensure that your camera is actually capturing to this palette beforehand. Capture Width/Height @@ -127,7 +127,7 @@ File File Path Enter the full path to the file to be used as the image source. File Colours - Specify the amount of colours in the image. Usually 24 bit colour. + Specify the amount of colours in the image. Usually 32 bit colour. Capture Width/Height As per local devices. Keep aspect ratio From c25dd50a21f37428e8cb546474be32caab16c8dc Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Tue, 20 Dec 2016 08:30:21 -0600 Subject: [PATCH 5/9] add Remote Protocol and Remote Method to the documentation --- docs/userguide/definemonitor.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/userguide/definemonitor.rst b/docs/userguide/definemonitor.rst index 7ecd0c922..dbc3e259d 100644 --- a/docs/userguide/definemonitor.rst +++ b/docs/userguide/definemonitor.rst @@ -108,6 +108,10 @@ Orientation Remote ^^^^^^ +Remote Protocol + Choices are currently HTTP and RTSP. Before RTSP became the industry standard, many ip cameras streamed directly from their web portal. If you have an ip camera that does not speak RTSP then choose HTTP here. If you camera does speak RTSP then you should change your source type to ffmpeg instead of selecting RTSP here. The Remote -> RTSP method is no longer being maintained and may go away at some point in the future. +Remote Method + When HTTP is the Remote Protocol, your choices are Simple and Regexp. Most should choose Simple. When RTSP is the Remote Protocol, your choices are RTP/Unicast, RTP/Multicast, RTP/RTSP, RTP,RTSP,HTTP. Try each of these to determine which works with your camera. Most cameras will use either RTP/Unicast (UDP) or RTP/RTSP (TCP). Remote Host/Port/Path Use these fields to enter the full URL of the camera. Basically if your camera is at http://camserver.home.net:8192/cameras/camera1.jpg then these fields will be camserver.home.net, 8192 and /cameras/camera1.jpg respectively. Leave the port at 80 if there is no special port required. If you require authentication to access your camera then add this onto the host name in the form :@.com. This will usually be 32 or 24 bit colour even if the image looks black and white. Look in Supported Hardware > Network Cameras section, how to obtain these strings that may apply to your camera. Remote Image Colours From a20da2aa7167ffb66a671838c433b4fef4c7af70 Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Tue, 20 Dec 2016 08:47:02 -0600 Subject: [PATCH 6/9] modify ffmpeg documentation, add a note to libvlc source type --- docs/userguide/definemonitor.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/userguide/definemonitor.rst b/docs/userguide/definemonitor.rst index dbc3e259d..60f174d39 100644 --- a/docs/userguide/definemonitor.rst +++ b/docs/userguide/definemonitor.rst @@ -71,11 +71,16 @@ Source Tab FFmpeg ^^^^^^ - + This is the recommended source type for most modern ip cameras. Source Path - Use this field to enter the full URL of the stream or file. Look in Supported Hardware > Network Cameras section, how to obtain these strings that may apply to your camera. RTSP streams may be specified here. + Use this field to enter the full URL of the stream or file your camera supports. This is usually an RTSP url. There are several methods to learn this: + * Check the documentation that came with your camera + * Look for your camera in the hardware compatibilty list in the wiki http://wiki.zoneminder.com/Hardware_Compatibilty_List + * Try ZoneMinder's new ONVIF probe feature + * Download and install the ONVIF Device Manager onto a Windows machine https://sourceforge.net/projects/onvifdm/ + * Use Google to find third party sites, such as ispy, which document this information Source Colours - Specify the amount of colours in the captured image. Unlike with local cameras changing this has no controlling effect on the remote camera itself so ensure that your camera is actually capturing to this palette beforehand. + Specify the amount of colours in the captured image. 32 bit is the preferred choice here. Unlike with local cameras changing this has no controlling effect on the remote camera itself so ensure that your camera is actually capturing to this palette beforehand. Capture Width/Height Make sure you enter here the same values as they are in the remote camera's internal setting. Keep aspect ratio @@ -85,6 +90,7 @@ Orientation LibVLC ^^^^^^ + The fields for the LibVLC source type are configured the same way as the ffmpeg source type. We recommend only using this source type if issues are experienced with the ffmpeg source type. cURL ^^^^ From 454894e3e8f3b89fac081fa9b6e08705bf28dd2d Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Tue, 20 Dec 2016 11:30:19 -0600 Subject: [PATCH 7/9] fix rst formatting It is amazing how seemingly small changes in whitespace significantly affect the formatting --- docs/userguide/definemonitor.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/userguide/definemonitor.rst b/docs/userguide/definemonitor.rst index 60f174d39..5a6d17cd8 100644 --- a/docs/userguide/definemonitor.rst +++ b/docs/userguide/definemonitor.rst @@ -74,6 +74,7 @@ FFmpeg This is the recommended source type for most modern ip cameras. Source Path Use this field to enter the full URL of the stream or file your camera supports. This is usually an RTSP url. There are several methods to learn this: + * Check the documentation that came with your camera * Look for your camera in the hardware compatibilty list in the wiki http://wiki.zoneminder.com/Hardware_Compatibilty_List * Try ZoneMinder's new ONVIF probe feature From 02dac96cd920ad409cee9df69f04d59afa7a01a9 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Tue, 20 Dec 2016 11:33:14 -0600 Subject: [PATCH 8/9] more rst formatting changes make the note about using ffmpeg over remote->rtsp in bold --- docs/userguide/definemonitor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/userguide/definemonitor.rst b/docs/userguide/definemonitor.rst index 5a6d17cd8..6fe946c28 100644 --- a/docs/userguide/definemonitor.rst +++ b/docs/userguide/definemonitor.rst @@ -116,7 +116,7 @@ Remote ^^^^^^ Remote Protocol - Choices are currently HTTP and RTSP. Before RTSP became the industry standard, many ip cameras streamed directly from their web portal. If you have an ip camera that does not speak RTSP then choose HTTP here. If you camera does speak RTSP then you should change your source type to ffmpeg instead of selecting RTSP here. The Remote -> RTSP method is no longer being maintained and may go away at some point in the future. + Choices are currently HTTP and RTSP. Before RTSP became the industry standard, many ip cameras streamed directly from their web portal. If you have an ip camera that does not speak RTSP then choose HTTP here. **If you camera does speak RTSP then you should change your source type to ffmpeg instead of selecting RTSP here.** The Remote -> RTSP method is no longer being maintained and may go away at some point in the future. Remote Method When HTTP is the Remote Protocol, your choices are Simple and Regexp. Most should choose Simple. When RTSP is the Remote Protocol, your choices are RTP/Unicast, RTP/Multicast, RTP/RTSP, RTP,RTSP,HTTP. Try each of these to determine which works with your camera. Most cameras will use either RTP/Unicast (UDP) or RTP/RTSP (TCP). Remote Host/Port/Path From c6368c4a1ad6c989d58ef23963d04db9dab7227d Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Tue, 20 Dec 2016 13:49:07 -0600 Subject: [PATCH 9/9] replace zmMemInvalidate with zmMemDetach --- scripts/zmtrigger.pl.in | 2 +- scripts/zmwatch.pl.in | 7 ++++--- scripts/zmx10.pl.in | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/zmtrigger.pl.in b/scripts/zmtrigger.pl.in index 2f180e090..b3de9f433 100644 --- a/scripts/zmtrigger.pl.in +++ b/scripts/zmtrigger.pl.in @@ -418,7 +418,7 @@ while( 1 ) foreach my $monitor ( values(%monitors) ) { # Free up any used memory handle - zmMemInvalidate( $monitor ); + zmMemDetach( $monitor ); } loadMonitors(); } diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index c35c4ea8a..9a850663f 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -89,8 +89,8 @@ while( 1 ) my $restart = 0; # Prevent open handles building up if we have connect to shared memory # Many of our error checks below do a next without closing the mem handle. - # zmMemInvalidate will just return of nothing is open, so we can just do this here. - zmMemInvalidate( $monitor ); + # zmMemDetach will just return of nothing is open, so we can just do this here. + zmMemDetach( $monitor ); if ( zmMemVerify( $monitor ) && zmMemRead( $monitor, "shared_data:valid" ) ) @@ -141,6 +141,7 @@ while( 1 ) { $command = "zmdc.pl restart zmc -m $monitor->{Id}"; } + zmMemDetach( $monitor ); # Close our file handle to the zmc process we are about to end runCommand( $command ); } elsif ( $monitor->{Function} ne 'Monitor' ) @@ -184,7 +185,7 @@ while( 1 ) } # end if restart } # end if check analysis daemon # Prevent open handles building up if we have connect to shared memory - zmMemInvalidate( $monitor ); + zmMemDetach( $monitor ); } # end foreach monitor sleep( $Config{ZM_WATCH_CHECK_INTERVAL} ); } # end while (1) diff --git a/scripts/zmx10.pl.in b/scripts/zmx10.pl.in index 8daa63c87..856f163d6 100644 --- a/scripts/zmx10.pl.in +++ b/scripts/zmx10.pl.in @@ -580,7 +580,7 @@ sub loadTasks } } } - zmMemInvalidate( $monitor ); + zmMemDetach( $monitor ); } }