Skip to content

Server which connects to set of existing RTSP's and provides HLS/MSE-based streams.

License

Notifications You must be signed in to change notification settings

LdDl/video-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc Sourcegraph Go Report Card GitHub tag

Golang-based video-server for re-streaming RTSP to HLS/MSE

Table of Contents

About

Simple WS/HTTP server for re-streaming video (RTSP) to client in MSE/HLS format.

It is highly inspired by https://github.com/deepch and his projects. So why am I trying to reinvent the wheel? Well, I'm just trying to fit my needs.

Instalation

Binaries

Linux - link

From source

go get github.com/LdDl/video-server
# or just clone it
# git clone https://github.com/LdDl/video-server.git

Go to root folder of downloaded repository, move to cmd/video_server folder:

cd $CLONED_PATH/cmd/video_server
go build -o video_server main.go

Usage

video_server -h
-conf string
    Path to configuration either TOML-file or JSON-file (default "conf.toml")
-cpuprofile file
    write cpu profile to file
-memprofile file
    write memory profile to file

Start server

Prepare configuration file (example here). Then run binary:

video_server --conf=conf.toml

Test Client-Server

For HLS-based player go to hls-subdirectory.

For MSE-based (websockets) player go to mse-subdirectory.

Then follow this set of commands:

npm install
export NODE_OPTIONS=--openssl-legacy-provider
npm run dev

You will se something like this after succesfull fron-end start:

DONE  Compiled successfully in 1783ms                                                                                                                                                                         12:09:30 PM
App running at:
- Local:   http://localhost:8080/ 

Paste link to the browser and check if video loaded successfully.

Archive

You can configure application to write MP4 chunks of custom duration (but not less than first keyframe duration) to the filesystem or S3 MinIO

  • For storing archive to the filesystem. Point default directory for storing MP4 files and duration:

    [archive]
    enabled = true
    directory = "./mp4"
    ms_per_file = 30000

    For each stream configuration you can override default directory and duration. Field "type" should have value "filesystem":

    [[rtsp_streams]]
    # ...
    # Some other single stream props
    # ...
    archive = { enabled = true, ms_per_file = 20000, type = "filesystem", directory = "custom_folder" } 
  • For storing archive to the S3 MinIO: Modify configuration file to have both filesystem and minio configuration (filesystem will be picked for storing temporary files before moving it to the MinIO), e.g.:

    [archive]
    enabled = true
    directory = "./mp4"
    ms_per_file = 30000
    minio_settings = { host = "localhost", port = 29199, user = "minio_secret_login", password = "minio_secret_password", default_bucket = "archive-bucket", default_path = "/var/archive_data" }

    For each stream configuration you can override default directory for temporary files, MinIO bucket and path in it and chunk duration. Field "type" should have value "minio":

    [[rtsp_streams]]
    # ...
    # Some other single stream props
    # ...
    archive = { enabled = true, ms_per_file = 20000, type = "minio", "directory": "custom_folder", minio_bucket = "vod-bucket", minio_path = "/var/archive_data_custom" }
  • If you want disable archive for specified stream, just set value of the field enabled to false in streams array. For disabling archive at all you can do the same but in the main configuration (where default values are set)

  • To install MinIO (in case if you want to store archive in S3) you can use [./docker-compose.yaml](docker-compose file) or [./scripts/minio-ansible.yml](Ansible script) for example of deployment workflows

Dependencies

GIN web-framework - https://github.com/gin-gonic/gin. License is MIT

Media library - http://github.com/deepch/vdk. License is MIT.

UUID generation and parsing - https://github.com/google/uuid. License is BSD 3-Clause

Websockets - https://github.com/gorilla/websocket. License is BSD 2-Clause

m3u8 library - https://github.com/grafov/m3u8. License is BSD 3-Clause

errors wrapping - https://github.com/pkg/errors . License is BSD 2-Clause

License

You can check it here

Developers

Roman - https://github.com/webver

Pavel - https://github.com/Pavel7824

Dimitrii Lopanov - https://github.com/LdDl

Morozka - https://github.com/morozka