Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrisan committed Aug 11, 2019
2 parents d29d81e + 6dafab2 commit d64a0d3
Show file tree
Hide file tree
Showing 13 changed files with 541 additions and 349 deletions.
2 changes: 1 addition & 1 deletion extra/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ ADD extra/motioneye.conf.sample /usr/share/motioneye/extra/

CMD test -e /etc/motioneye/motioneye.conf || \
cp /usr/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf ; \
/usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf -d
/usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf

EXPOSE 8765
3 changes: 2 additions & 1 deletion extra/Dockerfile.armv7-armhf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ RUN apt-get update && \
git clone --depth 1 https://github.com/Hexxeh/rpi-firmware.git /tmp/rpi-firmware && \
cp -rv /tmp/rpi-firmware/vc/hardfp/opt/vc /opt && \
rm -rf /tmp/rpi-firmware && \
ln -sf /opt/vc/bin/vcgencmd /usr/bin/vcgencmd && \
curl -L --output /tmp/motion.deb https://github.com/Motion-Project/motion/releases/download/release-4.2.2/pi_stretch_motion_4.2.2-1_armhf.deb && \
dpkg -i /tmp/motion.deb && \
rm /tmp/motion.deb && \
Expand All @@ -66,6 +67,6 @@ ADD extra/motioneye.conf.sample /usr/share/motioneye/extra/

CMD test -e /etc/motioneye/motioneye.conf || \
cp /usr/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf ; \
/usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf -d
/usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf

EXPOSE 8765
2 changes: 1 addition & 1 deletion extra/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: "2"
services:
motioneye:
image: cahna/motioneye
image: ccrisan/motioneye:master-amd64 # Change to ccrisan/motioneye:master-armhf for ARM chips (Pi etc.)
ports:
- "8081:8081"
- "8765:8765"
Expand Down
25 changes: 12 additions & 13 deletions motioneye/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
'text_left',
'text_right',
'threshold',
'threshold_maximum',
'threshold_tune',
'videodevice',
'vid_control_params',
'webcontrol_interface',
Expand Down Expand Up @@ -500,13 +502,6 @@ def add_camera(device_details):
if device_details['port']:
host += ':' + str(device_details['port'])

if device_details['username'] and proto == 'mjpeg':
if device_details['password']:
host = device_details['username'] + ':' + device_details['password'] + '@' + host

else:
host = device_details['username'] + '@' + host

device_details['url'] = urlparse.urlunparse(
(device_details['scheme'], host, device_details['path'], '', '', ''))

Expand Down Expand Up @@ -621,7 +616,6 @@ def rem_camera(camera_id):

def main_ui_to_dict(ui):
data = {
'@show_advanced': ui['show_advanced'],
'@admin_username': ui['admin_username'],
'@normal_username': ui['normal_username']
}
Expand Down Expand Up @@ -666,7 +660,6 @@ def call_hook(u, p):

def main_dict_to_ui(data):
ui = {
'show_advanced': data['@show_advanced'],
'admin_username': data['@admin_username'],
'normal_username': data['@normal_username']
}
Expand Down Expand Up @@ -766,6 +759,8 @@ def motion_camera_ui_to_dict(ui, prev_config=None):
'emulate_motion': False,
'text_changes': ui['show_frame_changes'],
'locate_motion_mode': ui['show_frame_changes'],
'threshold_maximum': ui['max_frame_change_threshold'],
'threshold_tune': ui['auto_threshold_tuning'],
'noise_tune': ui['auto_noise_detect'],
'noise_level': max(1, int(round(int(ui['noise_level']) * 2.55))),
'lightswitch_percent': ui['light_switch_detect'],
Expand Down Expand Up @@ -830,6 +825,7 @@ def motion_camera_ui_to_dict(ui, prev_config=None):
threshold = int(float(ui['frame_change_threshold']) * 640 * 480 / 100)

data['threshold'] = threshold


if (ui['storage_device'] == 'network-share') and settings.SMB_SHARES:
mount_point = smbctl.make_mount_point(ui['network_server'], ui['network_share_name'], ui['network_username'])
Expand Down Expand Up @@ -1133,6 +1129,8 @@ def motion_camera_dict_to_ui(data):
'motion_detection': data['@motion_detection'],
'show_frame_changes': data['text_changes'] or data['locate_motion_mode'],
'auto_noise_detect': data['noise_tune'],
'max_frame_change_threshold': data['threshold_maximum'],
'auto_threshold_tuning': data['threshold_tune'],
'noise_level': int(int(data['noise_level']) / 2.55),
'light_switch_detect': data['lightswitch_percent'],
'despeckle_filter': data['despeckle_filter'],
Expand Down Expand Up @@ -1381,7 +1379,7 @@ def motion_camera_dict_to_ui(data):
command_notifications = []
for e in on_event_start:
if e.count(' sendmail '):
e = shlex.split(e)
e = shlex.split(utils.make_str(e)) # poor shlex can't deal with unicode properly

if len(e) < 10:
continue
Expand All @@ -1405,7 +1403,7 @@ def motion_camera_dict_to_ui(data):
ui['email_notifications_picture_time_span'] = 0

elif e.count(' webhook '):
e = shlex.split(e)
e = shlex.split(utils.make_str(e)) # poor shlex can't deal with unicode properly

if len(e) < 3:
continue
Expand Down Expand Up @@ -1449,7 +1447,7 @@ def motion_camera_dict_to_ui(data):
command_storage = []
for e in on_movie_end:
if e.count(' webhook '):
e = shlex.split(e)
e = shlex.split(utils.make_str(e)) # poor shlex can't deal with unicode properly

if len(e) < 3:
continue
Expand Down Expand Up @@ -1836,7 +1834,6 @@ def _dict_to_conf(lines, data, list_names=None):
def _set_default_motion(data):
data.setdefault('@enabled', True)

data.setdefault('@show_advanced', False)
data.setdefault('@admin_username', 'admin')
data.setdefault('@admin_password', '')
data.setdefault('@normal_username', 'user')
Expand Down Expand Up @@ -1903,6 +1900,8 @@ def _set_default_motion_camera(camera_id, data):
data.setdefault('locate_motion_style', 'redbox')

data.setdefault('threshold', 2000)
data.setdefault('threshold_maximum', 0)
data.setdefault('threshold_tune', False)
data.setdefault('noise_tune', True)
data.setdefault('noise_level', 32)
data.setdefault('lightswitch_percent', 0)
Expand Down
7 changes: 7 additions & 0 deletions motioneye/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,9 @@ def authorize(self, camera_id):


class PictureHandler(BaseHandler):
def compute_etag(self):
return None

@asynchronous
def get(self, camera_id, op, filename=None, group=None):
if camera_id is not None:
Expand Down Expand Up @@ -954,6 +957,9 @@ def post(self, camera_id, op, filename=None, group=None):
@BaseHandler.auth(prompt=False)
def current(self, camera_id, retry=0):
self.set_header('Content-Type', 'image/jpeg')
self.set_header('Cache-Control', 'no-store, must-revalidate')
self.set_header('Pragma', 'no-cache')
self.set_header('Expires', '0')

width = self.get_argument('width', None)
height = self.get_argument('height', None)
Expand Down Expand Up @@ -1783,6 +1789,7 @@ def upload_media_file(self, filename, camera_id, camera_config):

tasks.add(5, uploadservices.upload_media_file, tag='upload_media_file(%s)' % filename,
camera_id=camera_id, service_name=service_name,
camera_name=camera_config['camera_name'],
target_dir=camera_config['@upload_subfolders'] and camera_config['target_dir'],
filename=filename)

Expand Down
2 changes: 1 addition & 1 deletion motioneye/scripts/relayevent.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

if [ -z "$3" ]; then
echo "Usage: $0 <motioneye.conf> <event> <motion_camera_id> [filename]"
Expand Down
15 changes: 7 additions & 8 deletions motioneye/static/js/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function setupCameraFrame() {
/* error and load handlers */
cameraImg.error(function () {
this.error = true;
this.loading = 0;
this.loading_count = 0;

cameraImg.addClass('error').removeClass('loading');
cameraPlaceholder.css('opacity', 1);
Expand All @@ -42,7 +42,7 @@ function setupCameraFrame() {
}

this.error = false;
this.loading = 0;
this.loading_count = 0;

cameraImg.removeClass('error').removeClass('loading');
cameraPlaceholder.css('opacity', 0);
Expand Down Expand Up @@ -106,11 +106,11 @@ function refreshCameraFrame() {
return;
}

if (img.loading) {
img.loading++; /* increases each time the camera would refresh but is still loading */
if (img.loading_count) {
img.loading_count++; /* increases each time the camera would refresh but is still loading */

if (img.loading > 2 * 1000 / refreshInterval) { /* limits the retry at one every two seconds */
img.loading = 0;
if (img.loading_count > 2 * 1000 / refreshInterval) { /* limits the retry at one every two seconds */
img.loading_count = 0;
}
else {
return; /* wait for the previous frame to finish loading */
Expand All @@ -125,7 +125,7 @@ function refreshCameraFrame() {

path = addAuthParams('GET', path);
img.src = path;
img.loading = 1;
img.loading_count = 1;

cameraFrame.refreshDivider = 0;
})();
Expand All @@ -141,4 +141,3 @@ $(document).ready(function () {
setupCameraFrame();
refreshCameraFrame();
});

Loading

0 comments on commit d64a0d3

Please sign in to comment.