ghostream

command module
v0.0.0-...-f7cf187 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 13 Imported by: 0

README

Ghostream

PkgGoDev Go Report Card pipeline status coverage report Docker Cloud Build Status

Boooo! A simple streaming server with authentication and open-source technologies.

This project was developped at Cr@ns to stream events.

Features:

  • WebRTC playback with a lightweight web interface.
  • SRT stream input, supported by FFMpeg, OBS and Gstreamer.
  • Low-latency streaming, sub-second with web player.
  • Authentication of incoming stream using LDAP server.
  • Possibility to forward stream to other streaming servers.

Installation on Debian/Ubuntu

On Ubuntu 20.10+ or Debian 11+, you can install directly ghostream,

sudo apt install git golang ffmpeg libsrt1-openssl
go get gitlab.crans.org/nounous/ghostream

On Ubuntu 20.04 or Debian Buster, you may manually install libsrt 1.4.1: install libsrt1-openssl 1.4.1 then libsrt-openssl-dev 1.4.1.

For development, you may clone this repository, then go run main.go.

Installation with Docker

An example is given in docs/docker-compose.yml. It uses Traefik reverse proxy.

You can also launch the Docker image using,

docker build . -t ghostream
docker run -it --rm -p 2112:2112 -p 9710:9710/udp -p 8080:8080 -p 10000-10005:10000-10005/udp ghostream

Configuration

Ghostream can be configured by placing ghostream.yml in /etc/ghostream/. You can overwrite the configuration path with GHOSTREAM_CONFIG environnement variable. You can also overwride any value using environnement variables, e.g. GHOSTREAM_AUTH_BACKEND=ldap will change the authentification backend.

Streaming

As stated by OBS wiki, when streaming you should adapt the latency to 2.5 * (the round-trip time with server, in μs).

With OBS

As OBS uses FFMpeg, you need to have FFMpeg compiled with SRT support. To check if SR is available, run ffmpeg -protocols | grep srt. On Windows and MacOS, OBS comes with his own FFMpeg that will work.

In OBS, go to "Settings" -> "Output" -> "Recording" the select "Output to URL" and change the URL to srt://127.0.0.1:9710?streamid=demo:demo. For container, you may use MPEGTS for now (will change).

With GStreamer

To stream your X11 screen,

gst-launch-1.0 ximagesrc startx=0 show-pointer=true use-damage=0 \
! videoconvert \
! x264enc bitrate=32000 tune=zerolatency speed-preset=veryfast byte-stream=true threads=1 key-int-max=15 intra-refresh=true ! video/x-h264, profile=baseline, framerate=30/1 \
! mpegtsmux \
! srtserversink uri=srt://127.0.0.1:9710/ latency=1000000 streamid=demo:demo

This might not work at the moment.

Playing stream

With a web browser and WebRTC

Ghostream expose a web server on 0.0.0.0:8080 by default. By opening this in a browser, you will be able to get instructions on how to stream, and if you append /streamname to the URL, then you will be able to watch the stream named streamname.

The web player also integrates a side widget that is configurable.

Integrate the player in an iframe

To integrate the player without the side widget, you can append ?nowidget to the URL.

<iframe src="https://example.com/stream_name?nowidget" scrolling="no" allowfullscreen="true" width="1280" height="750.4" frameborder="0"></iframe>

The iframe size should be a 16/9 ratio, with additionnal 30.4px for the control bar.

With ffplay

You may directly open the SRT stream with ffplay:

ffplay -fflags nobuffer srt://127.0.0.1:9710?streamid=demo
With MPV

As MPV uses ffmpeg libav, support for SRT streams can be easily added. See current pull request.

Troubleshooting

ld returns an error when launching ghostream

When missing libsrt-openssl-dev on Debian/Ubuntu, then srtgo package is unable to build.

~/ghostream$ go run main.go
# github.com/haivision/srtgo
/usr/bin/ld: cannot find -lsrt
/usr/bin/ld: cannot find -lsrt
/usr/bin/ld: cannot find -lsrt
collect2: error: ld returned 1 exit status

References

Documentation

Overview

Package main provides the full-featured server with configuration loading and communication between routines.

Directories

Path Synopsis
Package auth manages backends to auth incoming streams
Package auth manages backends to auth incoming streams
basic
Package basic provides a basic authentification backend
Package basic provides a basic authentification backend
ldap
Package ldap provides a LDAP authentification backend
Package ldap provides a LDAP authentification backend
internal
config
Package config loads application settings
Package config loads application settings
monitoring
Package monitoring serves Prometheus monitoring endpoints
Package monitoring serves Prometheus monitoring endpoints
Package messaging defines a structure to communication between inputs and outputs Package messaging defines a structure to communication between inputs and outputs Package messaging defines a structure to communication between inputs and outputs
Package messaging defines a structure to communication between inputs and outputs Package messaging defines a structure to communication between inputs and outputs Package messaging defines a structure to communication between inputs and outputs
stream
forwarding
Package forwarding forwards incoming stream to other streaming services
Package forwarding forwards incoming stream to other streaming services
ovenmediaengine
Package ovenmediaengine provides the forwarding to an ovenmediaengine server to handle the web client
Package ovenmediaengine provides the forwarding to an ovenmediaengine server to handle the web client
srt
Package srt serves a SRT server Package srt serves a SRT server
Package srt serves a SRT server Package srt serves a SRT server
telnet
Package telnet expose text version of stream.
Package telnet expose text version of stream.
webrtc
Package webrtc provides the backend to simulate a WebRTC client to send stream Package webrtc provides the backend to simulate a WebRTC client to send stream
Package webrtc provides the backend to simulate a WebRTC client to send stream Package webrtc provides the backend to simulate a WebRTC client to send stream
Package transcoder manages transcoders
Package transcoder manages transcoders
text
Package text transcode a video to text
Package text transcode a video to text
Package web serves the JavaScript player and WebRTC negotiation Package web serves the JavaScript player and WebRTC negotiation Package web serves the JavaScript player and WebRTC negotiation
Package web serves the JavaScript player and WebRTC negotiation Package web serves the JavaScript player and WebRTC negotiation Package web serves the JavaScript player and WebRTC negotiation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL