Skip to content

Instantly share code, notes, and snippets.

@spikedrba
Forked from waveform80/lots_of_jpegs.py
Last active August 29, 2015 14:17
Show Gist options
  • Save spikedrba/792e5eefffd51bea36b9 to your computer and use it in GitHub Desktop.
Save spikedrba/792e5eefffd51bea36b9 to your computer and use it in GitHub Desktop.
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