Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement libcamerify support for motion binary #2765

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions motioneye/extra/motioneye.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ 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".
# 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)
#motion_binary /usr/bin/motion

Expand Down
17 changes: 17 additions & 0 deletions motioneye/motionctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ 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

def start(deferred=False):
from motioneye import config, mjpgclient
Expand Down Expand Up @@ -100,6 +113,10 @@ def start(deferred=False):
motion_pid_path = os.path.join(settings.RUN_PATH, 'motion.pid')

args = [program, '-n', '-c', motion_config_path, '-d']
libcamerify = find_libcamerify()
if libcamerify:
logging.debug('Using libcamera wrapper libcamerify')
args.insert(0, libcamerify)

if settings.LOG_LEVEL <= logging.DEBUG:
args.append('9')
Expand Down
8 changes: 8 additions & 0 deletions motioneye/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
# the TCP port to listen on
PORT = 8765

# 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".
# 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)
MOTION_BINARY = None

Expand Down
Loading