Archive of https://github.com/drakmor/srt2hls — Simple audio HLS streaming server based on Liquidsoap https://github.com/drakmor/srt2hls
  • Liquidsoap 83%
  • Dockerfile 9.8%
  • Python 7.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2020-04-13 14:36:42 +02:00
img Update readme, remove todo 2019-12-12 15:20:16 +01:00
liquidsoap Use local gpg key for liquidsoap repository 2019-12-02 10:55:47 +01:00
monitoring Better dashboard 2019-12-09 18:00:48 +01:00
nginxhls Switch to separate nginx conf file and update liquidsoap to master 2019-12-12 15:19:48 +01:00
radio Update liquidsoap to the latest master 2020-04-13 14:36:42 +02:00
.gitignore Update liquidsoap and use better bitrate values 2019-09-28 12:44:17 +02:00
COPYING Add COPYING GNU GPLv3 2019-09-22 20:17:45 +02:00
docker-compose.yml Update liquidsoap to the latest master 2020-04-13 14:36:42 +02:00
radio.py Remove Telnet API (redudant with http) 2019-12-09 16:58:35 +01:00
README.md Update readme, remove todo 2019-12-12 15:20:16 +01:00

srt2hls

Simple audio HLS streaming server.

Intro

The goal of this program is to receive an audio stream with SRT and broadcast it with HLS. It can serve as a CDN origin server or as a set-and-forget streaming server.

How it works

srt2hls use Liquidsoap to receive a stream and encode it in HLS, then it use [nginx] (https://www.nginx.com/) to serve HLS content.

The Liquidsoap container, by default, run radio/live.liq script. It's a fully functionnal example that will :

  1. Receive an SRT input on port 10000
  2. Encode it in aac with 3 quality
  3. Segment it in HLS format in /hls directory

The Nginx container come with a specific configuration to serve HLS content with proper Content-Type, CORS and Cache-Control headers. It need read only access to /hls directory to serve HLS segments and playlists.

Setup

With docker compose

mkdir hls
chown -R 2001:2000 hls
sudo docker-compose up

Local installation requirements

Liquidsoap 1.5.0+ (not released yet, use master)

ffmpeg compiled with fdkaac support (the one on liquidsoap debian/ubuntu repository is fine)

Basic usage

Listening

By default the encoder send blank HLS segments, that mean if it's started, you can already listen the blank stream.

ffplay http://localhost:8080/live.m3u8
vlc http://localhost:8080/live.m3u8

Switch live source

The default script allow to switch the output between inputs.

# Check available input to switch to
curl http://localhost:8080/api/list?livesource
# Switch the livesource
curl http://localhost:8080/api/set?livesource=srt2
curl http://localhost:8080/api/set?livesource=srt1
# check the current live source
curl http://localhost:8080/api/get?livesource

Sending audio to the streaming server

Using ffmpeg

Requirement : ffmpeg compiled with srt support (the one on liquidsoap debian/ubuntu repository is fine)

# static file
ffmpeg -re -i $AUDIOFILE -vn -f wav -codec:a pcm_s16le srt://127.0.0.1:10000
# live stream
ffmpeg -i $LIVESTREAM -vn -f wav -codec:a pcm_s16le srt://127.0.0.1:10000

Monitoring

Grafana

http://localhost:3000/

Alt text

Prometheus

http://localhost:9090/

Development

Build images

sudo docker-compose build

Thanks

Folks of Liquidsoap

Monitoring stack is mostly inspired by https://github.com/stefanprodan/dockprom