Use RTSP streaming and post-processing simultaneously

Hi to all,

I’m currenty struggeling with the usage of the functionality to provide a stream via RTSP and use the post-processing for motion detection simultaneously with libcamera-vid.

I can provide a stream with the following command and it is working:

libcamera-vid -n -t 0 --inline --width 1920 --height 1080 --framerate 30 -o - | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream}' :demux=h264

I can also use the motion dectection with the following command and get an output on the cli when a motion is detected:

libcamera-vid -t 0 -n --inline --lores-width 128 --lores-height 96 --post-process-file motion_detect.json

But i did not get both of them working simultaneously. Is this even possible? Or is there maybe an other solution?

Greetz

Hi,

If you want to get both of them working simultaneously, the camera resource would be busy…

Hello,

I randomly found this post, but a few months back I created a new version of libcamera-vid that combines motion detection with recording live video.

If you follow the guide on here: https://www.raspberrypi.com/documentation/computers/camera_software.html#building-libcamera-and-libcamera-apps with my version of the repository:
https://github.com/stefanderaadt/libcamera-apps you get a new command called libcamera-motion.

Here is an example command I used for testing my code:

libcamera-motion --lores-width 128 --lores-height 96 --post-process-file ../assets/motion_detect.json --inline --circular 40 --motion-output motion --output -

Detected motions get written to a file called motion-(datetime).h264