waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.57k stars 357 forks source link

Taking images in intervals while picamera is streaming via mjpeg #643

Open ballchuuu opened 4 years ago

ballchuuu commented 4 years ago

Hi, I would like to take images in 3 second intervals while picamera is streaming via mjpeg. However, it seems like the server thread cannot be broken once it has started which means I cannot add a while True loop to take images at intervals. May I know if there is any possible way at doing this? Thank you

output = StreamingOutput()
while True:
    camera.start_recording(output, format='mjpeg')
    # to take images here at 3 seconds intervals while the stream continues
try:
    address = ('', 8000)
    server = StreamingServer(address, StreamingHandler)
    server.serve_forever()
    print("here")

finally:
    camera.stop_recording()