Is it possible instead of copying a variable content to a given location ( stream.copy_to('motion.h264') ) save it in a variable to be further processed. Reason I would like to do so, is to be able to downgrade video resolution once the video buffer has been collected.
Thanks in advance!
import io
import random
import picamera
def motion_detected():
# Randomly return True (like a fake motion detection routine)
return random.randint(0, 10) == 0
camera = picamera.PiCamera()
stream = picamera.PiCameraCircularIO(camera, seconds=20)
camera.start_recording(stream, format='h264')
try:
while True:
camera.wait_recording(1)
if motion_detected():
# Keep recording for 10 seconds and only then write the
# stream to disk
camera.wait_recording(10)
stream.copy_to('motion.h264')
finally:
camera.stop_recording()