From 377028de9f9ba612dc6ecd2451ea904dfa894fd0 Mon Sep 17 00:00:00 2001 From: Stian Date: Fri, 19 May 2023 13:00:31 +0200 Subject: [PATCH 1/7] Implement support for libcamerify wrapper --- motioneye/motionctl.py | 28 +++++++++++++++++++++++++++- motioneye/settings.py | 3 +++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 272e487af..7217299a7 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -69,6 +69,21 @@ def find_motion(): return _motion_binary_cache +def find_libcamerify(): + + if settings.LIBCAMERIFY: + + if os.path.exists(settings.LIBCAMERIFY): + logging.debug(f'Found {settings.LIBCAMERIFY}') + return settings.LIBCAMERIFY + + else: + binary = utils.call_subprocess(['which', 'libcamerify']) + if os.path.exists(binary): + logging.debug(f'Found {binary}') + return binary + + return None, None def start(deferred=False): from motioneye import config, mjpgclient @@ -99,7 +114,18 @@ def start(deferred=False): motion_log_path = os.path.join(settings.LOG_PATH, 'motion.log') motion_pid_path = os.path.join(settings.RUN_PATH, 'motion.pid') - args = [program, '-n', '-c', motion_config_path, '-d'] + args = [] + + libcamerify = find_libcamerify() + if libcamerify: + args.append(libcamerify) + logging.debug('Using libcam wrapper libcamerify') + + args.append(program) + args.append('-n') + args.append('-c') + args.append(motion_config_path) + args.append('-d') if settings.LOG_LEVEL <= logging.DEBUG: args.append('9') diff --git a/motioneye/settings.py b/motioneye/settings.py index 33b0bb18f..e9b5cd8a7 100644 --- a/motioneye/settings.py +++ b/motioneye/settings.py @@ -59,6 +59,9 @@ # the TCP port to listen on PORT = 8765 +# Path to libcamerify if libcamera compatability layer/wrapper should be used (default no) +LIBCAMERIFY = None + # path to the motion binary to use (automatically detected by default) MOTION_BINARY = None From fbdabaf76a239b1c680081faea1609fe84e037ec Mon Sep 17 00:00:00 2001 From: Stian Indal Haugseth Date: Mon, 22 May 2023 10:22:48 +0200 Subject: [PATCH 2/7] Change return to single value Co-authored-by: MichaIng --- motioneye/motionctl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 7217299a7..6400f41d8 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -83,7 +83,7 @@ def find_libcamerify(): logging.debug(f'Found {binary}') return binary - return None, None + return None def start(deferred=False): from motioneye import config, mjpgclient From 4f6ce2ab9fe4d98a01ff9baf71c05277d97c2c67 Mon Sep 17 00:00:00 2001 From: Stian Indal Haugseth Date: Mon, 22 May 2023 10:25:00 +0200 Subject: [PATCH 3/7] Remove empty lines Co-authored-by: MichaIng --- motioneye/motionctl.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 6400f41d8..7c736091c 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -70,9 +70,7 @@ def find_motion(): return _motion_binary_cache def find_libcamerify(): - if settings.LIBCAMERIFY: - if os.path.exists(settings.LIBCAMERIFY): logging.debug(f'Found {settings.LIBCAMERIFY}') return settings.LIBCAMERIFY From ed917059fa72ccc02a3a7a08c7055446aca3daa4 Mon Sep 17 00:00:00 2001 From: Stian Indal Haugseth Date: Mon, 22 May 2023 10:26:53 +0200 Subject: [PATCH 4/7] Update motioneye/motionctl.py Co-authored-by: MichaIng --- motioneye/motionctl.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 7c736091c..fb8bba6a2 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -112,18 +112,11 @@ def start(deferred=False): motion_log_path = os.path.join(settings.LOG_PATH, 'motion.log') motion_pid_path = os.path.join(settings.RUN_PATH, 'motion.pid') - args = [] - + args = [program, '-n', '-c', motion_config_path, '-d'] libcamerify = find_libcamerify() if libcamerify: - args.append(libcamerify) - logging.debug('Using libcam wrapper libcamerify') - - args.append(program) - args.append('-n') - args.append('-c') - args.append(motion_config_path) - args.append('-d') + logging.debug('Using libcamera wrapper libcamerify') + args.insert(0, libcamerify) if settings.LOG_LEVEL <= logging.DEBUG: args.append('9') From af91ff42dfc6b93e2f77b0097123862bebe173c0 Mon Sep 17 00:00:00 2001 From: Stian Date: Mon, 22 May 2023 11:58:50 +0200 Subject: [PATCH 5/7] Updated sample config --- motioneye/extra/motioneye.conf.sample | 7 +++++++ motioneye/settings.py | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/motioneye/extra/motioneye.conf.sample b/motioneye/extra/motioneye.conf.sample index b5505819f..131945ca2 100644 --- a/motioneye/extra/motioneye.conf.sample +++ b/motioneye/extra/motioneye.conf.sample @@ -20,6 +20,13 @@ listen 0.0.0.0 # the TCP port to listen on port 8765 +# path to libcamerify for backwards compatability when using libcamera +# This should only be used on Raspberry Pi with Bullseye or newer when you can not use the legacy camera libraries like raspicam. +# If you have Raspberry Pi Camera v3 or newer you probably have to use this or some other workaround like a local IP-camera. +# Libcamerify enables a way to access a libcamera-camera using the legacy APIs and will probably not support all if any camera parameters. +# Libcamerify can be installed with "sudo apt install libcamera-tools". +#libcamerify /usr/bin/libcamerify + # path to the motion binary to use (automatically detected if commented) #motion_binary /usr/bin/motion diff --git a/motioneye/settings.py b/motioneye/settings.py index e9b5cd8a7..05308cc20 100644 --- a/motioneye/settings.py +++ b/motioneye/settings.py @@ -59,7 +59,11 @@ # the TCP port to listen on PORT = 8765 -# Path to libcamerify if libcamera compatability layer/wrapper should be used (default no) +# path to libcamerify for backwards compatability when using libcamera +# This should only be used on Raspberry Pi with Bullseye or newer when you can not use the legacy camera libraries like raspicam. +# If you have Raspberry Pi Camera v3 or newer you probably have to use this or some other workaround like a local IP-camera. +# Libcamerify enables a way to access a libcamera-camera using the legacy APIs and will probably not support all if any camera parameters. +# Libcamerify can be installed with "sudo apt install libcamera-tools". LIBCAMERIFY = None # path to the motion binary to use (automatically detected by default) From 9add88a3cac83bfef745b068fe70ad954a7ce4b9 Mon Sep 17 00:00:00 2001 From: Stian Date: Mon, 22 May 2023 12:33:20 +0200 Subject: [PATCH 6/7] Updated sample config describing dependency to newer Motion release. --- motioneye/extra/motioneye.conf.sample | 1 + motioneye/settings.py | 1 + 2 files changed, 2 insertions(+) diff --git a/motioneye/extra/motioneye.conf.sample b/motioneye/extra/motioneye.conf.sample index 131945ca2..135acae2e 100644 --- a/motioneye/extra/motioneye.conf.sample +++ b/motioneye/extra/motioneye.conf.sample @@ -25,6 +25,7 @@ port 8765 # If you have Raspberry Pi Camera v3 or newer you probably have to use this or some other workaround like a local IP-camera. # Libcamerify enables a way to access a libcamera-camera using the legacy APIs and will probably not support all if any camera parameters. # Libcamerify can be installed with "sudo apt install libcamera-tools". +# Warning: needs Motion release newer than release 4.5.1. As of 2023-05-23 Motion needs to be compiled manually. See https://github.com/Motion-Project/motion/issues/1644 #libcamerify /usr/bin/libcamerify # path to the motion binary to use (automatically detected if commented) diff --git a/motioneye/settings.py b/motioneye/settings.py index 05308cc20..38845b22e 100644 --- a/motioneye/settings.py +++ b/motioneye/settings.py @@ -64,6 +64,7 @@ # If you have Raspberry Pi Camera v3 or newer you probably have to use this or some other workaround like a local IP-camera. # Libcamerify enables a way to access a libcamera-camera using the legacy APIs and will probably not support all if any camera parameters. # Libcamerify can be installed with "sudo apt install libcamera-tools". +# Warning: needs Motion release newer than release 4.5.1. As of 2023-05-23 Motion needs to be compiled manually. See https://github.com/Motion-Project/motion/issues/1644 LIBCAMERIFY = None # path to the motion binary to use (automatically detected by default) From 2842da780a232aaa475704564f2342aeca86b493 Mon Sep 17 00:00:00 2001 From: Stian Date: Mon, 22 May 2023 15:11:50 +0200 Subject: [PATCH 7/7] Corrected misspelled words --- motioneye/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/motioneye/settings.py b/motioneye/settings.py index 38845b22e..11791fff1 100644 --- a/motioneye/settings.py +++ b/motioneye/settings.py @@ -59,8 +59,8 @@ # the TCP port to listen on PORT = 8765 -# path to libcamerify for backwards compatability when using libcamera -# This should only be used on Raspberry Pi with Bullseye or newer when you can not use the legacy camera libraries like raspicam. +# path to libcamerify for backwards compatibility when using libcamera +# This should only be used on Raspberry Pi with Bullseye or newer when you cannot use the legacy camera libraries like raspicam. # If you have Raspberry Pi Camera v3 or newer you probably have to use this or some other workaround like a local IP-camera. # Libcamerify enables a way to access a libcamera-camera using the legacy APIs and will probably not support all if any camera parameters. # Libcamerify can be installed with "sudo apt install libcamera-tools".