Skip to content

Commit 3525a4b

Browse files
committed
Fix camera library for different OS releases (#1487)
1 parent ebd899c commit 3525a4b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ sudo service mycodoflask restart
3232
- Fix inability to set the same output for PID raise and lower ([#1369](https://github.com/kizniche/Mycodo/issues/1369))
3333
- Fix OpenWeather One Call API endpoint to use v3.0 ([#1429](https://github.com/kizniche/Mycodo/pull/1429))
3434
- Fix apt update not being run before installing apt packages dependencies
35+
- Fix camera library for different OS releases ([#1487](https://github.com/kizniche/Mycodo/pull/1487))
3536

3637
### Features
3738

mycodo/devices/camera.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,13 @@ def camera_record(record_type, unique_id, duration_sec=None, tmp_filename=None):
238238
logger.exception("raspistill")
239239

240240
elif settings.library == 'libcamera':
241-
if not os.path.exists("/usr/bin/libcamera-still"):
242-
logger.error("/usr/bin/libcamera-still not found")
241+
# Check for rpicam-still first (Bookworm), then fallback to libcamera-still
242+
if os.path.exists("/usr/bin/rpicam-still"):
243+
camera_cmd = "/usr/bin/rpicam-still"
244+
elif os.path.exists("/usr/bin/libcamera-still"):
245+
camera_cmd = "/usr/bin/libcamera-still"
246+
else:
247+
logger.error("Neither /usr/bin/rpicam-still nor /usr/bin/libcamera-still found")
243248
return None, None
244249

245250
try:
@@ -249,9 +254,9 @@ def camera_record(record_type, unique_id, duration_sec=None, tmp_filename=None):
249254
filename = f"{filename}.{settings.output_format.lower()}"
250255
path_file = os.path.join(save_path, filename)
251256

252-
cmd = f"/usr/bin/libcamera-still " \
257+
cmd = f"{camera_cmd} " \
253258
f"--width {settings.width} " \
254-
f"--height { settings.height} " \
259+
f"--height {settings.height} " \
255260
f"--brightness {settings.brightness} " \
256261
f"-o {path_file}"
257262

0 commit comments

Comments
 (0)