Assuming you want to record 10 seconds of video before motion is detected, and 10 seconds of video after motion is detected, you can simply create a circular buffer with enough space for 20 seconds of video, wait until motion is detected, then wait 10 seconds more, and only then write the contents of the circular buffer to disk. basic_circular.py
demonstrates this.
The second example is a little more complicated and results in a couple of files per motion event: the 10 seconds before and the all seconds that motion is still occurring after first detection. Once motion is detected, we start recording subsequent frames to a file, and while that's going on, dump the circular buffer to another file. Once we stop detecting motion, we close the "after" file, and split recording back to the circular stream. This is demonstrated in advanced_circular.py
.
Hi Dave,
according to you it is possible to web stream while capturing after a motion detection with the same Picamera?
Thx