From b0166b054c5fa2eff198aa67ed8545c20a7ae408 Mon Sep 17 00:00:00 2001 From: Joo Aun Saw Date: Mon, 28 Oct 2019 00:39:17 +1100 Subject: [PATCH] fnc rtsp: limit max resolution --- .../motioneye-modules/streameyectl.py | 48 ++++++++++++++++++- .../raspberrypi/overlay/usr/bin/streameye.sh | 8 ++++ .../motioneye-modules/streameyectl.py | 48 ++++++++++++++++++- .../raspberrypi2/overlay/usr/bin/streameye.sh | 8 ++++ .../motioneye-modules/streameyectl.py | 48 ++++++++++++++++++- .../raspberrypi3/overlay/usr/bin/streameye.sh | 8 ++++ .../motioneye-modules/streameyectl.py | 48 ++++++++++++++++++- .../raspberrypi4/overlay/usr/bin/streameye.sh | 8 ++++ 8 files changed, 220 insertions(+), 4 deletions(-) diff --git a/board/raspberrypi/motioneye-modules/streameyectl.py b/board/raspberrypi/motioneye-modules/streameyectl.py index 2a83fac414..c08a6a844e 100755 --- a/board/raspberrypi/motioneye-modules/streameyectl.py +++ b/board/raspberrypi/motioneye-modules/streameyectl.py @@ -124,6 +124,27 @@ RESOLUTION_CHOICES = [ ('3280x2464', '3280x2464') ] +RTSP_RESOLUTION_CHOICES = [ + ('320x200', '320x200'), + ('320x240', '320x240'), + ('640x480', '640x480'), + ('800x480', '800x480'), + ('800x600', '800x600'), + ('1024x576', '1024x576'), + ('1024x768', '1024x768'), + ('1280x720', '1280x720'), + ('1280x800', '1280x800'), + ('1280x960', '1280x960'), + ('1280x1024', '1280x1024'), + ('1296x972', '1296x972'), + ('1440x960', '1440x960'), + ('1440x1024', '1440x1024'), + ('1600x1200', '1600x1200'), + ('1640x922', '1640x922'), + ('1640x1232', '1640x1232'), + ('1920x1080', '1920x1080') +] + ROTATION_CHOICES = [ ('0', '0°'), ('90', '90°'), @@ -311,6 +332,8 @@ def _get_raspimjpeg_settings(camera_id): 'imxfx': 'none', 'width': 640, 'height': 480, + 'rtsp_width': 640, + 'rtsp_height': 480, 'rotation': 0, 'vflip': False, 'hflip': False, @@ -372,6 +395,7 @@ def _get_raspimjpeg_settings(camera_id): s['sharpness'] = (s['sharpness'] + 100) / 2 s['resolution'] = '%sx%s' % (s.pop('width'), s.pop('height')) + s['rtspResolution'] = '%sx%s' % (s.pop('rtsp_width'), s.pop('rtsp_height')) s = dict(('se' + n[0].upper() + n[1:], v) for (n, v) in s.items()) @@ -383,6 +407,8 @@ def _set_raspimjpeg_settings(camera_id, s): s['width'] = int(s['resolution'].split('x')[0]) s['height'] = int(s.pop('resolution').split('x')[1]) + s['rtsp_width'] = int(s['rtspResolution'].split('x')[0]) + s['rtsp_height'] = int(s.pop('rtspResolution').split('x')[1]) s['zoom'] = '%.2f,%.2f,%.2f,%.2f' % ( s.pop('zoomx') / 100.0, s.pop('zoomy') / 100.0, @@ -705,13 +731,33 @@ def seResolution(): return None return { - 'label': 'Video Resolution', + 'label': 'MJPEG Video Resolution', 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', 'type': 'choices', 'choices': RESOLUTION_CHOICES, 'section': 'device', 'camera': True, 'required': True, + 'depends': ['seProto==mjpeg'], + 'get': _get_raspimjpeg_settings, + 'set': _set_raspimjpeg_settings, + 'get_set_dict': True + } + +@additional_config +def seRtspResolution(): + if not _get_streameye_enabled(): + return None + + return { + 'label': 'RTSP Video Resolution', + 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', + 'type': 'choices', + 'choices': RTSP_RESOLUTION_CHOICES, + 'section': 'device', + 'camera': True, + 'required': True, + 'depends': ['seProto==rtsp'], 'get': _get_raspimjpeg_settings, 'set': _set_raspimjpeg_settings, 'get_set_dict': True diff --git a/board/raspberrypi/overlay/usr/bin/streameye.sh b/board/raspberrypi/overlay/usr/bin/streameye.sh index bb642cb8ac..6c9c26549d 100755 --- a/board/raspberrypi/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi/overlay/usr/bin/streameye.sh @@ -130,6 +130,14 @@ function start() { raspimjpeg_opts="${raspimjpeg_opts} --${line}" done < ${RASPIMJPEG_CONF} + video_height=$(grep -e ^rtsp_height ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_height}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --height ${video_height}" + fi + video_width=$(grep -e ^rtsp_width ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_width}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --width ${video_width}" + fi video_iso=$(grep -e ^iso ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) if [ -n "${video_iso}" ]; then raspimjpeg_opts="${raspimjpeg_opts} --ISO ${video_iso}" diff --git a/board/raspberrypi2/motioneye-modules/streameyectl.py b/board/raspberrypi2/motioneye-modules/streameyectl.py index 2a83fac414..c08a6a844e 100755 --- a/board/raspberrypi2/motioneye-modules/streameyectl.py +++ b/board/raspberrypi2/motioneye-modules/streameyectl.py @@ -124,6 +124,27 @@ RESOLUTION_CHOICES = [ ('3280x2464', '3280x2464') ] +RTSP_RESOLUTION_CHOICES = [ + ('320x200', '320x200'), + ('320x240', '320x240'), + ('640x480', '640x480'), + ('800x480', '800x480'), + ('800x600', '800x600'), + ('1024x576', '1024x576'), + ('1024x768', '1024x768'), + ('1280x720', '1280x720'), + ('1280x800', '1280x800'), + ('1280x960', '1280x960'), + ('1280x1024', '1280x1024'), + ('1296x972', '1296x972'), + ('1440x960', '1440x960'), + ('1440x1024', '1440x1024'), + ('1600x1200', '1600x1200'), + ('1640x922', '1640x922'), + ('1640x1232', '1640x1232'), + ('1920x1080', '1920x1080') +] + ROTATION_CHOICES = [ ('0', '0°'), ('90', '90°'), @@ -311,6 +332,8 @@ def _get_raspimjpeg_settings(camera_id): 'imxfx': 'none', 'width': 640, 'height': 480, + 'rtsp_width': 640, + 'rtsp_height': 480, 'rotation': 0, 'vflip': False, 'hflip': False, @@ -372,6 +395,7 @@ def _get_raspimjpeg_settings(camera_id): s['sharpness'] = (s['sharpness'] + 100) / 2 s['resolution'] = '%sx%s' % (s.pop('width'), s.pop('height')) + s['rtspResolution'] = '%sx%s' % (s.pop('rtsp_width'), s.pop('rtsp_height')) s = dict(('se' + n[0].upper() + n[1:], v) for (n, v) in s.items()) @@ -383,6 +407,8 @@ def _set_raspimjpeg_settings(camera_id, s): s['width'] = int(s['resolution'].split('x')[0]) s['height'] = int(s.pop('resolution').split('x')[1]) + s['rtsp_width'] = int(s['rtspResolution'].split('x')[0]) + s['rtsp_height'] = int(s.pop('rtspResolution').split('x')[1]) s['zoom'] = '%.2f,%.2f,%.2f,%.2f' % ( s.pop('zoomx') / 100.0, s.pop('zoomy') / 100.0, @@ -705,13 +731,33 @@ def seResolution(): return None return { - 'label': 'Video Resolution', + 'label': 'MJPEG Video Resolution', 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', 'type': 'choices', 'choices': RESOLUTION_CHOICES, 'section': 'device', 'camera': True, 'required': True, + 'depends': ['seProto==mjpeg'], + 'get': _get_raspimjpeg_settings, + 'set': _set_raspimjpeg_settings, + 'get_set_dict': True + } + +@additional_config +def seRtspResolution(): + if not _get_streameye_enabled(): + return None + + return { + 'label': 'RTSP Video Resolution', + 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', + 'type': 'choices', + 'choices': RTSP_RESOLUTION_CHOICES, + 'section': 'device', + 'camera': True, + 'required': True, + 'depends': ['seProto==rtsp'], 'get': _get_raspimjpeg_settings, 'set': _set_raspimjpeg_settings, 'get_set_dict': True diff --git a/board/raspberrypi2/overlay/usr/bin/streameye.sh b/board/raspberrypi2/overlay/usr/bin/streameye.sh index bb642cb8ac..6c9c26549d 100755 --- a/board/raspberrypi2/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi2/overlay/usr/bin/streameye.sh @@ -130,6 +130,14 @@ function start() { raspimjpeg_opts="${raspimjpeg_opts} --${line}" done < ${RASPIMJPEG_CONF} + video_height=$(grep -e ^rtsp_height ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_height}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --height ${video_height}" + fi + video_width=$(grep -e ^rtsp_width ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_width}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --width ${video_width}" + fi video_iso=$(grep -e ^iso ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) if [ -n "${video_iso}" ]; then raspimjpeg_opts="${raspimjpeg_opts} --ISO ${video_iso}" diff --git a/board/raspberrypi3/motioneye-modules/streameyectl.py b/board/raspberrypi3/motioneye-modules/streameyectl.py index 2a83fac414..c08a6a844e 100755 --- a/board/raspberrypi3/motioneye-modules/streameyectl.py +++ b/board/raspberrypi3/motioneye-modules/streameyectl.py @@ -124,6 +124,27 @@ RESOLUTION_CHOICES = [ ('3280x2464', '3280x2464') ] +RTSP_RESOLUTION_CHOICES = [ + ('320x200', '320x200'), + ('320x240', '320x240'), + ('640x480', '640x480'), + ('800x480', '800x480'), + ('800x600', '800x600'), + ('1024x576', '1024x576'), + ('1024x768', '1024x768'), + ('1280x720', '1280x720'), + ('1280x800', '1280x800'), + ('1280x960', '1280x960'), + ('1280x1024', '1280x1024'), + ('1296x972', '1296x972'), + ('1440x960', '1440x960'), + ('1440x1024', '1440x1024'), + ('1600x1200', '1600x1200'), + ('1640x922', '1640x922'), + ('1640x1232', '1640x1232'), + ('1920x1080', '1920x1080') +] + ROTATION_CHOICES = [ ('0', '0°'), ('90', '90°'), @@ -311,6 +332,8 @@ def _get_raspimjpeg_settings(camera_id): 'imxfx': 'none', 'width': 640, 'height': 480, + 'rtsp_width': 640, + 'rtsp_height': 480, 'rotation': 0, 'vflip': False, 'hflip': False, @@ -372,6 +395,7 @@ def _get_raspimjpeg_settings(camera_id): s['sharpness'] = (s['sharpness'] + 100) / 2 s['resolution'] = '%sx%s' % (s.pop('width'), s.pop('height')) + s['rtspResolution'] = '%sx%s' % (s.pop('rtsp_width'), s.pop('rtsp_height')) s = dict(('se' + n[0].upper() + n[1:], v) for (n, v) in s.items()) @@ -383,6 +407,8 @@ def _set_raspimjpeg_settings(camera_id, s): s['width'] = int(s['resolution'].split('x')[0]) s['height'] = int(s.pop('resolution').split('x')[1]) + s['rtsp_width'] = int(s['rtspResolution'].split('x')[0]) + s['rtsp_height'] = int(s.pop('rtspResolution').split('x')[1]) s['zoom'] = '%.2f,%.2f,%.2f,%.2f' % ( s.pop('zoomx') / 100.0, s.pop('zoomy') / 100.0, @@ -705,13 +731,33 @@ def seResolution(): return None return { - 'label': 'Video Resolution', + 'label': 'MJPEG Video Resolution', 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', 'type': 'choices', 'choices': RESOLUTION_CHOICES, 'section': 'device', 'camera': True, 'required': True, + 'depends': ['seProto==mjpeg'], + 'get': _get_raspimjpeg_settings, + 'set': _set_raspimjpeg_settings, + 'get_set_dict': True + } + +@additional_config +def seRtspResolution(): + if not _get_streameye_enabled(): + return None + + return { + 'label': 'RTSP Video Resolution', + 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', + 'type': 'choices', + 'choices': RTSP_RESOLUTION_CHOICES, + 'section': 'device', + 'camera': True, + 'required': True, + 'depends': ['seProto==rtsp'], 'get': _get_raspimjpeg_settings, 'set': _set_raspimjpeg_settings, 'get_set_dict': True diff --git a/board/raspberrypi3/overlay/usr/bin/streameye.sh b/board/raspberrypi3/overlay/usr/bin/streameye.sh index bb642cb8ac..6c9c26549d 100755 --- a/board/raspberrypi3/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi3/overlay/usr/bin/streameye.sh @@ -130,6 +130,14 @@ function start() { raspimjpeg_opts="${raspimjpeg_opts} --${line}" done < ${RASPIMJPEG_CONF} + video_height=$(grep -e ^rtsp_height ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_height}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --height ${video_height}" + fi + video_width=$(grep -e ^rtsp_width ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_width}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --width ${video_width}" + fi video_iso=$(grep -e ^iso ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) if [ -n "${video_iso}" ]; then raspimjpeg_opts="${raspimjpeg_opts} --ISO ${video_iso}" diff --git a/board/raspberrypi4/motioneye-modules/streameyectl.py b/board/raspberrypi4/motioneye-modules/streameyectl.py index 2a83fac414..c08a6a844e 100755 --- a/board/raspberrypi4/motioneye-modules/streameyectl.py +++ b/board/raspberrypi4/motioneye-modules/streameyectl.py @@ -124,6 +124,27 @@ RESOLUTION_CHOICES = [ ('3280x2464', '3280x2464') ] +RTSP_RESOLUTION_CHOICES = [ + ('320x200', '320x200'), + ('320x240', '320x240'), + ('640x480', '640x480'), + ('800x480', '800x480'), + ('800x600', '800x600'), + ('1024x576', '1024x576'), + ('1024x768', '1024x768'), + ('1280x720', '1280x720'), + ('1280x800', '1280x800'), + ('1280x960', '1280x960'), + ('1280x1024', '1280x1024'), + ('1296x972', '1296x972'), + ('1440x960', '1440x960'), + ('1440x1024', '1440x1024'), + ('1600x1200', '1600x1200'), + ('1640x922', '1640x922'), + ('1640x1232', '1640x1232'), + ('1920x1080', '1920x1080') +] + ROTATION_CHOICES = [ ('0', '0°'), ('90', '90°'), @@ -311,6 +332,8 @@ def _get_raspimjpeg_settings(camera_id): 'imxfx': 'none', 'width': 640, 'height': 480, + 'rtsp_width': 640, + 'rtsp_height': 480, 'rotation': 0, 'vflip': False, 'hflip': False, @@ -372,6 +395,7 @@ def _get_raspimjpeg_settings(camera_id): s['sharpness'] = (s['sharpness'] + 100) / 2 s['resolution'] = '%sx%s' % (s.pop('width'), s.pop('height')) + s['rtspResolution'] = '%sx%s' % (s.pop('rtsp_width'), s.pop('rtsp_height')) s = dict(('se' + n[0].upper() + n[1:], v) for (n, v) in s.items()) @@ -383,6 +407,8 @@ def _set_raspimjpeg_settings(camera_id, s): s['width'] = int(s['resolution'].split('x')[0]) s['height'] = int(s.pop('resolution').split('x')[1]) + s['rtsp_width'] = int(s['rtspResolution'].split('x')[0]) + s['rtsp_height'] = int(s.pop('rtspResolution').split('x')[1]) s['zoom'] = '%.2f,%.2f,%.2f,%.2f' % ( s.pop('zoomx') / 100.0, s.pop('zoomy') / 100.0, @@ -705,13 +731,33 @@ def seResolution(): return None return { - 'label': 'Video Resolution', + 'label': 'MJPEG Video Resolution', 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', 'type': 'choices', 'choices': RESOLUTION_CHOICES, 'section': 'device', 'camera': True, 'required': True, + 'depends': ['seProto==mjpeg'], + 'get': _get_raspimjpeg_settings, + 'set': _set_raspimjpeg_settings, + 'get_set_dict': True + } + +@additional_config +def seRtspResolution(): + if not _get_streameye_enabled(): + return None + + return { + 'label': 'RTSP Video Resolution', + 'description': 'the video resolution (larger values produce better quality but require more CPU power, larger storage space and bandwidth)', + 'type': 'choices', + 'choices': RTSP_RESOLUTION_CHOICES, + 'section': 'device', + 'camera': True, + 'required': True, + 'depends': ['seProto==rtsp'], 'get': _get_raspimjpeg_settings, 'set': _set_raspimjpeg_settings, 'get_set_dict': True diff --git a/board/raspberrypi4/overlay/usr/bin/streameye.sh b/board/raspberrypi4/overlay/usr/bin/streameye.sh index bb642cb8ac..6c9c26549d 100755 --- a/board/raspberrypi4/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi4/overlay/usr/bin/streameye.sh @@ -130,6 +130,14 @@ function start() { raspimjpeg_opts="${raspimjpeg_opts} --${line}" done < ${RASPIMJPEG_CONF} + video_height=$(grep -e ^rtsp_height ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_height}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --height ${video_height}" + fi + video_width=$(grep -e ^rtsp_width ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) + if [ -n "${video_width}" ]; then + raspimjpeg_opts="${raspimjpeg_opts} --width ${video_width}" + fi video_iso=$(grep -e ^iso ${RASPIMJPEG_CONF} | cut -d ' ' -f 2) if [ -n "${video_iso}" ]; then raspimjpeg_opts="${raspimjpeg_opts} --ISO ${video_iso}"