Unable to open camera(): Cannot allocate memory #1893
-
I’m using motion built from current master, running on a Raspberry Pi Zero 2 W, using the Pi Camera module (OV5647) and the libcamera stack on Raspberry Pi OS Bookworm. Im having issue with memory allocation:
I’m launching motion wrapped in libcamerify so it gets /dev/video0 as a V4L2 source from libcamera.
motion.conf:
camera1.conf:
I’ve tried gpu_mem from 128 up to 320. libcamera-hello works perfectly at full 1080p. Using libcamera-vid with v4l2loopback works — so the hardware is fine. Dropping to 720p helps but doesn’t always fix the buffer issue when using libcamerify. When I run:
I consistently get:
And logs confirm:
So even though I’m asking for ~960×540 output, the sensor is always running in 1080p mode, so the DMA ring wants enough buffers for full 1080p RAW frames, then downscales. Is there any official or recommended way to tune the buffer_count when using libcamerify? Or should I always prefer libcamera-vid → v4l2loopback when I need to lock sensor resolution and keep the buffer pool small? Is there a libcamerify env var or option I’m missing? Are there known best practices for getting around the fact that the sensor mode doesn’t shrink when you downscale? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I also run rpicam-vid on a Zero 2W, but not motion itself. My stream runs 1920x1080 with only 4 buffers. Motion is on a different server and i stream from the Pi zero 2W to this server. I have a setup of this somewhere with my rpicam-vid scripts in detail: |
Beta Was this translation helpful? Give feedback.
-
Looks like there might be other issues going on there, permissions, etc.?
|
Beta Was this translation helpful? Give feedback.
I also run rpicam-vid on a Zero 2W, but not motion itself. My stream runs 1920x1080 with only 4 buffers. Motion is on a different server and i stream from the Pi zero 2W to this server. I have a setup of this somewhere with my rpicam-vid scripts in detail:
https://www.wetransco.de/
Maybe you find some help there.