Skip to content

Commit

Permalink
Add Motionplus release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Dave committed Mar 23, 2024
1 parent 7eb293b commit 5e7f9be
Show file tree
Hide file tree
Showing 7 changed files with 4,210 additions and 18 deletions.
79 changes: 66 additions & 13 deletions motionplus_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,27 +415,31 @@ <h2><a name="Configuration_OptionsTopic"></a> Configuration Options-Listed by T
<tbody>
<tr>
<td bgcolor="#edf4f9" ><a href="#webcontrol_port" >webcontrol_port</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_port2" >webcontrol_port2</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_ipv6" >webcontrol_ipv6</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_localhost" >webcontrol_localhost</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_parms" >webcontrol_parms</a> </td>
</tr>
<tr>
<td bgcolor="#edf4f9" ><a href="#webcontrol_parms" >webcontrol_parms</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_interface" >webcontrol_interface</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_auth_method" >webcontrol_auth_method</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_authentication" >webcontrol_authentication</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_tls" >webcontrol_tls</a> </td>
</tr>
<tr>
<td bgcolor="#edf4f9" ><a href="#webcontrol_tls" >webcontrol_tls</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_cert" >webcontrol_cert</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_key" >webcontrol_key</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_headers" >webcontrol_headers</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_actions" >webcontrol_actions</a> </td>
</tr>
<tr>
<td bgcolor="#edf4f9" ><a href="#webcontrol_actions" >webcontrol_actions</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_html" >webcontrol_html</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_base_path" >webcontrol_base_path</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_lock_attempts" >webcontrol_lock_attempts</a> </td>
</tr>
<tr>
<td bgcolor="#edf4f9" ><a href="#webcontrol_lock_minutes" >webcontrol_lock_minutes</a> </td>
<td bgcolor="#edf4f9" ><a href="#webcontrol_lock_script" >webcontrol_lock_script</a> </td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -1091,13 +1095,32 @@ <h3><a name="libcam_params"></a>libcam_params</h3>
<li> AwbCustom = 7</li>
</ul></div>
<i><h4> AwbLocked(bool)</h4></i>
<i><h4> ColourGains(Pipe delimited)</h4></i>
<div><ul>
<li> Red | Blue</li>
</ul></div>
<i><h4> ColourTemperature(int)</h4></i>
<i><h4> Saturation(float)</h4></i>
<i><h4> SensorBlackLevels(Pipe delimited)</h4></i>
<div><ul>
<li> var1|var2|var3|var4</li>
</ul></div>
<i><h4> Sharpness(float)</h4></i>
<i><h4> FocusFoM(int)</h4></i>
<i><h4> ScalerCrop(Rect x-y-h-w)</h4></i>
<i><h4> ColourCorrectionMatrix(Pipe delimited)</h4></i>
<div><ul>
<li> var1|var2|var3|var4|var5|var6|var7|var8|var9</li>
</ul></div>
<i><h4> ScalerCrop(Pipe delimited)</h4></i>
<div><ul>
<li> x|y|height|width</li>
</ul></div>
<i><h4> DigitalGain(float)</h4></i>
<i><h4> FrameDuration(int)</h4></i>
<i><h4> FrameDurationLimits(Pipe delimited)</h4></i>
<div><ul>
<li> min|max</li>
</ul></div>
<i><h4> SensorTemperature(float)</h4></i>
<i><h4> SensorTimestamp(int)</h4></i>
<i><h4> AfMode(int)</h4></i>
Expand All @@ -1122,7 +1145,10 @@ <h3><a name="libcam_params"></a>libcam_params</h3>
<li> AfMeteringAuto = 0</li>
<li> AfMeteringWindows = 1</li>
</ul></div>
<i><h4> AfWindows(rect x-y-h-w)</h4></i>
<i><h4> AfWindows(Pipe delimited)</h4></i>
<div><ul>
<li> x|y|height|width</li>
</ul></div>
<i><h4> AfTrigger(int)</h4></i>
<div><ul>
<li> AfTriggerStart = 0</li>
Expand Down Expand Up @@ -1189,12 +1215,6 @@ <h3><a name="libcam_params"></a>libcam_params</h3>
<li> LensShadingMapModeOff = 0</li>
<li> LensShadingMapModeOn = 1</li>
</ul></div>
<i><h4> SceneFlicker(int)</h4></i>
<div><ul>
<li> SceneFickerOff = 0</li>
<li> SceneFicker50Hz = 1</li>
<li> SceneFicker60Hz = 2</li>
</ul></div>
<i><h4> PipelineDepth(int)</h4></i>
<i><h4> MaxLatency(int)</h4></i>
<i><h4> TestPatternMode(int)</h4></i>
Expand Down Expand Up @@ -1339,7 +1359,7 @@ <h3><a name="rotate"></a> rotate </h3>

<h3><a name="flip_axis"></a> flip_axis </h3>
<ul>
<li> Values: none, v, h | Default: none</li>
<li> Values: none, vertical, horizontal | Default: none</li>
Flip the image according to specified axis.
</ul>
<p></p>
Expand Down Expand Up @@ -1846,7 +1866,7 @@ <h3><a name="movie_quality"></a> movie_quality </h3>

<h3><a name="movie_container"></a> movie_container </h3>
<ul>
<li> Values: flv, ogg, vp8, mp4, mkv, hevc | Default: mkv</li>
<li> Values: flv, ogg, webm, mp4, mkv, hevc, mov | Default: mkv</li>
Container/Codec to be used for the video. Preferred codec can be appended e.g. <code>mkv:libx265</code>
</ul>
<p></p>
Expand Down Expand Up @@ -1962,6 +1982,15 @@ <h3><a name="webcontrol_port"></a> webcontrol_port </h3>
</ul>
<p></p>

<h3><a name="webcontrol_port2"></a> webcontrol_port </h3>
<ul>
<li>Values: 0 to 65535 | Default: 0 (disabled)</li>
Second port for the web control that does not use TLS. This allows for specifying one port that
provides a TLS connection (to be used externally) while this port serves the local lan without getting
certificate domain warnings.
</ul>
<p></p>

<h3><a name="webcontrol_ipv6"></a> webcontrol_ipv6 </h3>
<ul>
<li> Values: on, off | Default: off</li>
Expand Down Expand Up @@ -2090,6 +2119,30 @@ <h3><a name="webcontrol_html"></a> webcontrol_html</h3>
The full path and file name for a user specified html page to use as the webcontrol.
</ul>
<p></p>

<h3><a name="webcontrol_lock_attempts"></a> webcontrol_lock_attempt</h3>
<ul>
<li> Values: Integer | Default: 3</li>
Number of permitted attempts to log in before triggering lockout.
</ul>
<p></p>

<h3><a name="webcontrol_lock_minutes"></a> webcontrol_lock_minutes</h3>
<ul>
<li> Values: Integer | Default: 10</li>
Number of minutes that the IP will be locked out from further attempts to log in.
</ul>
<p></p>

<h3><a name="webcontrol_lock_script"></a> webcontrol_lock_script</h3>
<ul>
<li> Values: String | Default: Not Defined</li>
Script to execute when a lockout has been triggered. Two additional parameters are passed to this script
when executed. The number of times the userid failed as well as the IP address attempting to log in.
</ul>
<p></p>


</ul>

<h3><a name="OptDetail_Stream"></a> Live Stream</a> </h3>
Expand Down
161 changes: 156 additions & 5 deletions motionplus_examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ <h3><a name="Examples"></a> Examples</h3>
<li> <a href="#dnn_setup">DNN setup</a></li>
<li> <a href="#haar_train">Haar Model Training</a></li>
<li> <a href="#sound_sample">Sound Frequency Sample</a></li>
<li> <a href="#fail2ban">Fail2Ban example</a></li>
<li> <a href="#ptz">PTZ command examples</a></li>
<p></p>
<p></p>
</ul>
Expand Down Expand Up @@ -91,19 +93,19 @@ <h3><a name="extpipe_commands"></a>Sample extpipe commands</h3>
The following are some sample extpipe commands
<p></p>
<code>
movie_extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %fps
movie_extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of avi -o %f.avi - -fps %{fps}
</code>
<p></p>
<code>
movie_extpipe x264 - --input-res %wx%h --fps %fps --bitrate 2000 --preset ultrafast --quiet -o %f.mp4
movie_extpipe x264 - --input-res %wx%h --fps %{fps} --bitrate 2000 --preset ultrafast --quiet -o %f.mp4
</code>
<p></p>
<code>
movie_extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%fps -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %fps
movie_extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%{fps} -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %{fps}
</code>
<p></p>
<code>
movie_extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -vcodec libx264 -preset ultrafast -f mp4 %f.mp4
movie_extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %{fps} -i pipe:0 -vcodec libx264 -preset ultrafast -f mp4 %f.mp4
</code>
<p></p>
</ul>
Expand Down Expand Up @@ -172,7 +174,7 @@ <h3><a name="database_setup"></a>Database Setup</h3>
invited to provide suggestions and corrections to these steps.
<small><small><code>
<ul>
sudo apt install libmariadb-dev libmariadb3 mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server
sudo apt install libmariadb-dev libmariadb3 mariadb-client mariadb-client-core mariadb-common mariadb-server
<br>sudo mariadb
<ul>
GRANT ALL ON *.* TO 'YourUserNameHere'@'localhost' IDENTIFIED BY 'YourPasswordHere' WITH GRANT OPTION;
Expand Down Expand Up @@ -237,6 +239,14 @@ <h3><a name="webcontrol_pages"></a>Webcontrol pages</h3>
<li><code>{IP}:{port0}/{camid}/mjpg/motion</code> Stream of motion images for the camera as a mjpg</li>
<li><code>{IP}:{port0}/{camid}/mjpg/source</code> Source image stream of the camera as a mjpg</li>
</ul>
The following mpegts pages are available via the webcontrol. (Update automatically)
<ul>
<li><code>{IP}:{port0}/{camid}/mpegts</code> Primary stream for the camera updated as a mpeg transport stream</li>
<li><code>{IP}:{port0}/{camid}/mpegts/substream</code> Substream for the camera updated as a mpeg transport stream</li>
<li><code>{IP}:{port0}/{camid}/mpegts/motion</code> Stream of motion images for the camera as a mpeg transport stream</li>
<li><code>{IP}:{port0}/{camid}/mpegts/source</code> Source image stream of the camera as a mpeg transport stream</li>
</ul>

The following static pages are available via the webcontrol. (Update manually)
<ul>
<li><code>{IP}:{port0}/{camid}/static</code> Primary image for the camera</li>
Expand Down Expand Up @@ -442,6 +452,147 @@ <h3><a name="sound_sample"></a>Sound Frequency Sample</h3>

</ul>

<h3><a name="fail2ban"></a>Fail2Ban Example</h3>
<ul>
The following are example files to use with the fail2ban application. This allows users to ban IPs that
may be attempting to get in. This example was created using Debian 11. Adjust as appropriate for other
distros and versions.
<br>
Install fail2ban and create the following files:
<br>File 1:
<small><small><code><ul>
<br>&nbsp;# Fail2Ban configuration file: /etc/fail2ban/filter.d/motionplus.conf
<br>&nbsp;# Author: Mr Dave
<br>&nbsp;#
<br>&nbsp;[INCLUDES]
<br>&nbsp;# Read common prefixes. If any customizations available -- read them from common.local
<br>&nbsp;before = common.conf
<br>&nbsp;
<br>&nbsp;[Definition]
<br>&nbsp;daemon = nsd
<br>&nbsp;
<br>&nbsp;# Option: failregex
<br>&nbsp;# Notes.:
<br>&nbsp;#&nbsp; regex to match the log in failures messages in the logfile. The
<br>&nbsp;#&nbsp; host must be matched by a group named "host". The tag "&ltHOST&gt" can
<br>&nbsp;#&nbsp; be used for standard IP/hostname matching and is only an alias for
<br>&nbsp;#&nbsp; (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
<br>&nbsp;# Sample: Jul 01 02:50:32 [EMG][STR][00:wc00] webu_failauth_check: Ignoring connection from: 192.168.1.10
<br>&nbsp;# Values: TEXT
<br>&nbsp;
<br>&nbsp;failregex = ^.*Ignoring connection from: &ltHOST&gt$
<br>&nbsp;
<br>&nbsp;ignoreregex =
<br>&nbsp;
<br>&nbsp;datepattern = {^LN-BEG}Epoch
<br>&nbsp;&nbsp;&nbsp;&nbsp;{^LN-BEG}
<br>&nbsp;
</ul></code></small></small>
<br>File2:
<small><small><code><ul>
<br>&nbsp;#Fail2Ban Jail Configuration File: /etc/fail2ban/jail.d/motionplus-jail.conf
<br>&nbsp;[motionplus]
<br>&nbsp;enabled = true
<br>&nbsp;filter = motionplus
<br>&nbsp;logpath = /var/log/motionplus/motionplus.log
<br>&nbsp;bantime = 23h
<br>&nbsp;banaction = iptables-allports[blocktype="DROP"]
<br>&nbsp;maxretry = 0
<br>&nbsp;port = 0:65535
</ul></code></small></small>
<br>Make sure to adjust the log file location indicated in the jail file as well as how long to ban the IP address.
</ul>

<h3><a name="ptz"></a>PTZ command examples</h3>
<ul>
The following are some example sources and scripts to send PTZ (Pan Tilt Zoom) commands to cameras.
<br><br>
<a href="https://github.com/667bdrm/sofiactl">sofiactl</a> is a Perl script that can control many imported inexpensive cameras.
<br> Adjust script location, timing, cameraip, user, etc as appropriate.
<small><small><code><ul>
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;sofiactl.pl --user admin --host cameraip --port 34567 --command OPPTZControl --sd ZoomTile --s2 0.5
<br>&nbsp;&nbsp;sofiactl.pl --user admin --host cameraip --port 34567 --command OPPTZControl --sd ZoomWide --s2 0.5
<br>&nbsp;&nbsp;sofiactl.pl --user admin --host cameraip --port 34567 --command OPPTZControl --sd DirectionUp --s2 2.0
<br>&nbsp;&nbsp;sofiactl.pl --user admin --host cameraip --port 34567 --command OPPTZControl --sd DirectionDown --s2 2.0
<br>&nbsp;&nbsp;sofiactl.pl --user admin --host cameraip --port 34567 --command OPPTZControl --sd DirectionLeft --s2 2.0
<br>&nbsp;&nbsp;sofiactl.pl --user admin --host cameraip --port 34567 --command OPPTZControl --sd DirectionRight --s2 2.0
<br>&nbsp;exit
</ul></code></small></small>

<br>
<a href="https://github.com/Mr-Dave/camxmctl">camxmctl</a> is a c++ program with a sample HTML page that makes adjusting the parameters
easier. It reuses some of the code from Motionplus and is based upon the JSON files and commands in the
<a href="https://github.com/667bdrm/sofiactl">sofiactl</a> script.
<br> Adjust location, timing, cameraip, user, etc as appropriate.
<small><small><code><ul>
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp; tbd. Review sample page to see post commands.
<br>&nbsp;exit
</ul></code></small></small>

<br>
curl scripts. Example 1
<br> Adjust as appropriate.
<small><small><code><ul>
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=1' http://admin@cameraip:80/PTZ/1/TurnDown
<br>&nbsp;&nbsp;sleep 2
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=0' http://admin@cameraip:80/PTZ/1/TurnDown
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=1' http://admin@cameraip:80/PTZ/1/TurnLeft
<br>&nbsp;&nbsp;sleep 2
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=0' http://admin@cameraip:80/PTZ/1/TurnLeft
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=1' http://admin@cameraip:80/PTZ/1/TurnRight
<br>&nbsp;&nbsp;sleep 2
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=0' http://admin@cameraip:80/PTZ/1/TurnRight
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=1' http://admin@cameraip:80/PTZ/1/TurnUp
<br>&nbsp;&nbsp;sleep 2
<br>&nbsp;&nbsp;curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d 'Param1=0' http://admin@cameraip:80/PTZ/1/TurnUp
<br>&nbsp;exit
</ul></code></small></small>

<br>
curl scripts. Example 2
<br> Adjust as appropriate.
<small><small><code><ul>
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=left&-speed=45'
<br>&nbsp;&nbsp;sleep 1
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45'
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=right&-speed=45'
<br>&nbsp;&nbsp;sleep 1
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45'
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=down&-speed=45'
<br>&nbsp;&nbsp;sleep 1
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45'
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=up&-speed=45'
<br>&nbsp;&nbsp;sleep 1
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45'
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=zoomin&-speed=45'
<br>&nbsp;&nbsp;sleep 1
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45'
<br>&nbsp;exit
<br>&nbsp;#!/bin/bash
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=zoomout&-speed=45'
<br>&nbsp;&nbsp;sleep 1
<br>&nbsp;&nbsp;curl 'http://admin:admin@cameraip:80/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45'
<br>&nbsp;exit
</ul></code></small></small>
</ul>

</section>
</body>
Expand Down
Binary file added mp0.2.0/motionplus.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5e7f9be

Please sign in to comment.