bastidest / video-stream-http-proxy

Reads multiple video streams (e.g. RTSP) and outputs low-latency DASH streams, accessible via a HTTP connection, viewable via a simple web interface.
MIT License
1 stars 1 forks source link

Video Stream (ONVIF/RTSP/...) to HTTP/DASH Proxy

GitHub tag (latest SemVer) Docker Image Version (latest semver) Conventional Commits

This project reads multiple video streams (e.g. RTSP) and outputs low-latency DASH streams, accessible via a HTTP connection, viewable via a simple web interface. It handles many (>10) video streams with little without high CPU load if no video conversion is desired (e.g 4K -> 1080p or H265 -> H264).

Features

https://user-images.githubusercontent.com/1242917/178140875-1ed84e04-7654-4b87-99cf-374d834dbd03.mov

What is it for? / Why would I need this?

What does it do?

When a client connects to the website, the Node.js manager starts streaming from all video stream sources which you define in a configuration file. Using FFMPEG, the source streams are converted into DASH streams and temporarily stored in shared memory. NGINX serves the DASH files in the shared memory directly to your browser. Commands (PTZ, Pan Tilt Zoom) issued from your browser are forwarded to the Node.js Manager and sent to the camera.


                +-------------------+   +-------------------+
                | Docker Container  |   | Docker Container  |
+----------+    |   +--------+   +----------+   +--------+  |   +-----------+
| Camera 1 +----|-->| FFMPEG +-->|          |   |        |<-|---+ Browser 1 |
+----------+    |   +--------+   |          |   |        |  |   +-----------+
                |        |       |          |   |        |  |
+----------+    |   +--------+   |          |   |        |  |   +-----------+
| Camera 2 +----|-->| FFMPEG +-->| /dev/shm |<--+        |<-|---+ Browser 2 |
+----------+    |   +--------+   |          |   |        |  |   +-----------+
                |        |       |          |   | NGINX  |  |
+----------+    |   +--------+   |          |   |        |  |   +-----------+
| Camera 3 +----|-->| FFMPEG +-->|          |   |        |<-|---+ Browser . |
+----------+    |   +--------+   +----------+   |        |  |   +-----------+
     ^          |        |          |   |       |        |  |
     |          |  +-----------+  Ctrl Cmds     |        |  |   +-----------+
     |   PTZ    |  |  Node.js  |<---|---|-------+        |<-|---+ Browser N |
     +----------+--+  Manager  |    |   |       |        |  |   +-----------+
        ONVIF   |  +-----------+    |   |       +--------+  |
                +-------------------+   +-------------------+

Installation / Getting Started

  1. Copy the docker-compose.prod.yml template to wherever you want to deploy the application
  2. Replace the ${DOCKER_NGINX_VERSION} variable with your desired nginx version
  3. Create the config.toml configuration file
  4. Copy the nginx configuration template from nginx/nginx.conf and configure to your liking
  5. docker-compose up -d

Custom Encoding

If you want to re-encode video streams, modify the ffmpeg-wrapper.sh script to your requirements and bind-mount it into the backend container.

Configuration

The application is configured using a .toml or .json configuration file (see example configuration in config.toml). The TOML and JSON format is equivalent, but the config.toml file takes precedence over the config.json file. The configuration file must be mounted at /app/config.toml in the backend docker container (see docker-compose.prod.yml). A complete description of the TOML/JSON schema can be found in src/server/ConfigParser.ts.

.output_path

.sources[]

.sources[].id

.sources[].target_latency_secs

.sources[].rtsp{}

.sources[].rtsp{}.url

.sources[].onvif{}

.sources[].onvif{}.url

.sources[].onvif{}.profile

.sources[].onvif{}.protocol

Connection Strings

Development

  1. Clone repository
  2. ./start.sh dev -> Wait for the bash prompt
  3. Access the dev command by pressing the "up" arrow
  4. Visit http://localhost

Release Workflow with git-conventional-commits

  1. Determine version by git-conventional-commits version
  2. Update version in project files
    • Commit version bump git commit -am'build(release): bump project version to <version>'
  3. Generate change log by git-conventional-commits changelog --release <version> --file 'CHANGELOG.md'
    • Commit change log git commit -am'doc(release): create <version> change log entry'
  4. Tag commit with version git tag -a -m'build(release): <version>' '<version-prefix><version>'
  5. Push all changes git push
  6. Build and upload artifacts