Skip to content

Instantly share code, notes, and snippets.

@malefs
Forked from mic159/mjpeg_udp.py
Created June 2, 2017 13:55
Show Gist options
  • Select an option

  • Save malefs/be85b952277513fc6aabe4e1de1b9134 to your computer and use it in GitHub Desktop.

Select an option

Save malefs/be85b952277513fc6aabe4e1de1b9134 to your computer and use it in GitHub Desktop.
Raspberry Pi MJPEG stream over UDP
from picamera import PiCamera
from io import BytesIO
import socket
import time
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
with PiCamera(resolution='VGA', framerate=5) as camera:
time.sleep(2)
buff = BytesIO()
for _ in camera.capture_continuous(buff, format='mjpeg'):
sock.sendto(buff.getvalue(), ('10.10.0.10', 7000))
buff.seek(0)
buff.truncate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment