How to generate MJPEG stream from JPEG snapshots from different IP camera based on alarm

  bash, camera, mjpeg, python, snapshot

I want to make Linux script (bash or Python or PHP) that on my Raspberry generate Motion JPEG (MJPEG) stream with 1 FPS from static JPEG snapshots from IP cameras, based on conditional logic. I’m beginner

I will try to explain behavior in my own words.

----- begin of the script 1-second loop -----

Script will download the status of the IP camera motion detection alarm based on NodeRED in JSON format.

HTTP GET http://mynodered.ip/motionalarm?
Response { "alarmstatus": "inactive", "alarmdescription": "Motion alarm" }

IF alarmdescription is motion alarm and alarmstatus is inactive, download JPEG snapshot
from camera 1 pointed to the street, resize it from 4K to Full HD resolution, and
serve as a frame to MJPEG stream.

ELSEIF alarmdescription is motion alarm and alarmstatus is active, download JPEG snapshot
from camera 2 placed next to the door area, resize it from 4K to FullHD resolution and
serve as a frame to MJPEG stream.

delay 0,9 sec

----- go to the beginning of script ----

The result must be a continuous MJPEG stream with 1 FPS that often displaying images from camera 1 and if motion is detected close to the door, on next loop cycle is displayed image from camera 2. When the alarm turns off, displaying images back from camera 1.

Source: Python Questions

LEAVE A COMMENT