Monday, January 12, 2015

Stream The Raspberry Pi Camera over Websockets HTML5

I've been going through all the tutorials on how to get your pi camera to a webpage and hadn't found one that uses Websockets. So I tried it out and it worked quit well.

what you need:

  • Autobahn python websocket server
    • pip install autobahn[twisted]
  • picamera python library
  • My source at github:
    • source
    • You will have to copy the www directory to your '/usr/local/www' or change the source code to fit

The sample webpage on the github is a basic websocket client webpage that provides a couple of features.

Since my cam is hidden within a rpi picture frame (will blog soon on that project) there's a little black around the edges.  I circled the controls I wired into the websocket server. The buttons show a preview on the raspberry pi's screen. The slider changes the framerate (0-30 fps).

The stream is smooth but still delayed like most streams to the web.

I may make updates depending on interest but its not a priority on my list of pi projects.

Let me know in the comments :-)