I'm have the following hardware in use:
- Raspberry Pi 4 Modell B 8GB RAM
- Raspberry-Pi-OS 64 bit "Bullseye" with latest updates
- Raspberry Pi Camera Module 3
- Webcam 1080p with MJPEG output
- The software shall provide an output (e.g. on the cli or starts a scripts), when a motion in the live camera video is detected
- The system shall provide the camera video via RTSP to other clients in the local network (e.g. to VLC). The provided stream shall be compressed (e.g. h264) to save bandwith
- The CPU load shall be as low as possible.
Solution 1
I' used the included motion detection of libcamera-vid post processing with the following code in a script for the Camera Module 3:
Code: Select all
libcamera-vid -t 0 -n --inline --lores-width 128 --lores-height 96 --post-process-file motion_detect.json
Solution 2
I'm using the following code to provide a compressed RTSP stream via libcamera-vid and the Camera Module 3:
Code: Select all
libcamera-vid -n -t 0 --inline --width 1920 --height 1080 --framerate 15 -o - | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream}' :demux=h264
Solution 3
I additionally installed the linux software motion. For me it did not work directly together witch libcamera-vid, so I was using again the possibility of libcamera-vid to provide the compressed RTSP stream via the Camera Module 3 (requirement 2 fullfilled). This RTSP stream is then also provided to the motion software and here the motion is detected and a script can be excecuted (requirement 1 fullfilled). Unfortunately the CPU load is now very hight. I assume this is the case because motion can't do the motion detection directly on the h.264 stream and has to somehow transfers it in another format (this is only an assumption). Also deactivation of webstream in motion did not help.
Solution 4
I used v4l2 to get the stream from the Webcam 1080p into motion. This worked perfectly and a motion could be detected and a script was executed (requirement 1 fullfilled). The CPU load was also low (requirement 3 fullfilled). Unfortunately motion does not provide an compressed RTSP stream, but a not good compressed MJPEG stream to the network (requirement 2 is not fullfilled).
Summary
In the end nothing could fullfill all of my requirements. Do you have maybe an idea? Maybe you know a way how to provide the RTSP stream via libcamera-vid AND use the post-processing filter (combination of solution 2 and 1)?