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.
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 ..
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
Install websocket module with
pip3 install --user --upgrade websocket
Copy ws_client.html to $HOME/public_html/ws_client.html
Edit ws_serve.py for your ip camera address, username and password
-
Confirm that your Apache2 is working by pointing your browser to:
-
Start serving the websocket with:
python3 ws_serve.py
-
Point your browser to:
Live video rolls for a minute or so, until it stops. Don't no why, but you may continue from here.. :)
MIT
Copyright 2018 Sampsa Riikonen
Sampsa Riikonen