Simple audio HLS streaming server based on Liquidsoap
Simple audio HLS streaming server.
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.
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 :
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.
mkdir hls
sudo chown -R 10000:10001 hls
sudo docker-compose up
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
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
Requirement : ffmpeg compiled with srt support (https://johnvansickle.com/ffmpeg/ for example)
# live stream or static file
ffmpeg -re -i $AUDIOFILE -vn -f wav -codec:a pcm_s16le srt://127.0.0.1:10000
sudo docker-compose build
Folks of Liquidsoap
Monitoring stack is mostly inspired by https://github.com/stefanprodan/dockprom