-
-
Save spikedrba/792e5eefffd51bea36b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import picamera | |
class MyOutput(object): | |
def __init__(self): | |
self.file_num = 0 | |
self.output = None | |
def write(self, buf): | |
if buf.startswith(b'\xff\xd8'): | |
if self.output: | |
self.output.close() | |
self.file_num += 1 | |
self.output = io.open('%d.jpg' % self.file_num, 'wb') | |
self.output.write(buf) | |
with picamera.PiCamera() as camera: | |
camera.resolution = (1280, 720) | |
camera.start_recording(MyOutput(), format='mjpeg') | |
camera.wait_recording(10) | |
camera.stop_recording() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment