I'm running Pi 4 with a 5 megapixel OV5647 camera attached to its camera port. I'm using motion
to run motion detection, with the goal of running low-res stream at 2 frames per second for detection and ramping it up to 1080p 30 frames once motion is detected. So far I only found config options to increase framerate in motion
, and even that does not seem to work.
My motion.conf
file has, among other, following values (value comments came with default config):
# Image width (pixels). Valid range: Camera dependent, default: 320
width 1920
# Image height (pixels). Valid range: Camera dependent, default: 240
height 1080
# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 2
#########################################################################################
# The mini-http server listens to this port for requests (default: 0 = disabled)
stream_port 8081
# Quality of the jpeg (in percent) images produced (default: 50)
stream_quality 90
# Output frames at 1 fps when no motion is detected and increase to the
# rate given by stream_maxrate when motion is detected (default: off)
stream_motion on
# Maximum framerate for stream streams (default: 1)
stream_maxrate 30
Unfortunately, this does not seem to affect stream on port 8081
- it keeps going at 2 fps even when motion is detected. Furthermore, even if I change config to
framerate 30
I don't get more than 6 fps, whether there is motion or not, allthewhile htop
shows just 1 core busy and then maximum at 50%, even during 8081
stream active.
At the same time, I get 30fps 1080p from raspivid
. I can easily split raspivid
output and write it into several output streams in my app, so I was wondering, can I somehow feed it into motion
? Perhaps emulate a web-cam or ip-cam? Or, maybe, run some other form of motion detection on it?
P.S. I have considered running motion
until it detects something, then shutting its process down and starting raspivid
, but I'd like to avoid a few seconds lag that would exist before activating raspivid
stream in this case. AFAIU, raspivid
and motion
can't use the same camera directly at the same time?