• This repository has been archived on 07/Dec/2023
  • Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    HTML
  • Created almost 6 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Stream H264 to browsers with websocket and w3 media source extensions

Live H264 stream from RTSP camera to your browser

a new, completely rewritten version!

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

Video is streamed as H264 encapsulated in MP4. No transcoding takes place in the stream-to-browser pipeline. No browser-side 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.

Only H264 is supported - browser MSE's do not support H246 yet (and neither does libValkka).

How does it work?

Roughly like this:

server-side                                   nginx
    
ws_serve_new.py <-- websocket <---------------+-* <----+  <---- web browser        
                                              |        |
                    ws_client_new.html  <-----+        |
                            |                          |
                            +--------------------------+
                                  (requests websocket)

Starts nginx
Uses libValkka                     JavaScript
                                   W3 MediaSource Extension

The web-browser client uses the W3 Media Source Extensions to push the payload into browsers video decoding infrastructure.

Requirements

  • Install libValkka as instructed here
  • Install nginx with sudo apt-get install nginx
  • Install python websocket module with pip3 install --user websockets
  • Prepare nginx user rights:
sudo addgroup nginx
sudo chgrp nginx /var/lib/nginx
sudo adduser $USER nginx
sudo chmod g+r+w+x /var/lib/nginx
  • You need to do logout/login (so that group change takes effect)
  • Test if your nginx works correctly
nginx -p $PWD -c ./nginx.conf -g 'error_log error.log warn;'
  • Setup your camera so that it sends H264 only.

Usage

1. Start the program with

killall -9 nginx; python3 ws_serve_new.py rtsp://user:password@ip-address

An X-window is opened that shows you the live video stream.

2. Open your browser

Your low-latency live video is now available at http://localhost:8089

Now what?

  • Please tell me in the issues if this worked for you or not and what camera & other setup you are using
  • ..i.e. don't just report the bugs, but also successes! :)
  • If you want a more serious solution, please see this and this

References

License

MIT

Copyright

Copyright 2018-2020 Sampsa Riikonen

Author

Sampsa Riikonen

More Repositories

1

valkka-core

Valkka - Create video surveillance, management and analysis programs with PyQt
C++
186
star
2

valkka-live

OpenSource Video Surveillance Program
Python
31
star
3

btdemo

python bluetooth dbus demo
Python
21
star
4

valkka-examples

Valkka Python3 Examples
Python
17
star
5

opengl-texture-streaming

streaming textures with opengl
C++
15
star
6

task_thread

Concurrent Asynchronous Python
Python
14
star
7

darknet-python

Python3 API Darknet
C
13
star
8

cutefront

A Qt-like Javascript Frontend Framework
Python
9
star
9

valkka-streamer

IP camera analysis framework
JavaScript
7
star
10

valkka-onvif

libValkka Onvif Dependencies
Python
6
star
11

valkka-multiprocess

Python Multiprocessing Done Right
Python
5
star
12

skeleton

Python module template with autodocumentation and packaging
C++
4
star
13

cute_mongo_forms

Qt forms connected to document databases
Python
3
star
14

medium

My Medium articles with code samples
Python
2
star
15

aws-iot-testbed

AWS IoT docker and notebook simulator
Jupyter Notebook
2
star
16

home-ethereum

Instructions for running geth using a dedicated laptop
Shell
2
star
17

no-ip-systemd

A systemd client for no-ip service
Python
1
star
18

my_torch_project

A model pytorch project
Jupyter Notebook
1
star
19

cutefront-lib

Widget Library for CuteFront
JavaScript
1
star
20

valkka-cpp-examples

A scaffold for valkka extension modules
C++
1
star
21

homepage

My personal homepage
Shell
1
star
22

skeleton-cpp

Scaffold for cpp projects
CMake
1
star
23

geth-testbed

geth-based ethereum mini-network running in docker
Jupyter Notebook
1
star
24

webtools

Pyramid related web templating tools
Python
1
star