Code Monkey home page Code Monkey logo

websocket-live-streamer's Introduction

Livestreaming webcam through WebSockets

This is a proof-of-concept demo of using WebSockets to stream a video camera feed through WebSockets, so any browser can access it.

At the moment, it is very work-in-progress. The stream is coming in as the raw JPEG binary, which is then read as a blob that's loaded into an Image(), which is then drawn onto an HTML5 canvas.

The latency is about ~0.1s, but with relatively high CPU usage (NEW! Down from ~50% to ~20% CPU usage)

To demo this, make sure you have opencv-python and websockets installed, and you have Python 3.6+.

Demo

  1. Ensure you have the prerequisites, try pip install -r requirements.txt
  2. Run python server.py
  3. Visit localhost:8000 to view the stream. A corresponding window will also be loaded with the current time.

Running this in a Raspberry Pi

This currently works pretty well; I'm noticing ~0.4s latency between frames, but it runs at 30fps otherwise.

To try it out, make sure you have the v4l2 drivers installed. Then, enable it with sudo modprobe bcm2835-v4l2. You can add it at boot by adding bcm2835-v4l2 to /etc/modules.

websocket-live-streamer's People

Contributors

lcfyi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.