Giter Club home page Giter Club logo

websocket-mse-demo's Introduction

Live H264 stream from RTSP camera to your browser

It this rudimentary demo we're streaming live video from an RTSP camera to your HTML5 browser.

Video is streamed as H264 video stream encapsulated in MP4. No transcoding takes place. No flash or pure-javascript decoders required.

Video is decoded and presented in the browser using the W3 Media Source Extensions that is well supported by all major browsers by now.

How does it work?

Roughly like this:

server-side                   client side

ws_serve.py ==> websocket ==> ws_client.html

- FFmpeg                      - JavaScript
                              - W3 MediaSource Extension
  • Python program ws_serve.py is using ffmpeg as a slave process
  • It reads mp4 muxed video stream from ffmpeg's stdout
  • That stream is passed through websocket to ws_client.html
  • Client uses the W3 Media Source Extensions to push the payload into browsers video decoding infrastructure

To try it out follow the steps ..

1. Install Apache2 and configure it for websockets

Install Apache2 and some additional modules for it:

sudo apt install apache2
sudo a2enmod userdir
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel

Add to

/etc/apache2/sites-available/000-default.conf

The following lines

ProxyRequests Off 
ProxyPass /ws/  ws://example.com:3001

Make directory for user web content

cd
mkdir public_html
cd public_html 

Restart Apache2

systemctl restart apache2

2. Install python dependencies

Install websocket module with

pip3 install --user --upgrade websocket

3. Setup your files

Copy ws_client.html to $HOME/public_html/ws_client.html

Edit ws_serve.py for your ip camera address, username and password

4. Run it!

  1. Confirm that your Apache2 is working by pointing your browser to:

    http://localhost

  2. Start serving the websocket with:

    python3 ws_serve.py

  3. Point your browser to:

    http://localhost/~your_username/ws_client.html

Live video rolls for a minute or so, until it stops. Don't no why, but you may continue from here.. :)

License

MIT

Copyright

Copyright 2018 Sampsa Riikonen

Author

Sampsa Riikonen

websocket-mse-demo's People

Contributors

elsampsa avatar

Watchers

James Cloos 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.