Code Monkey home page Code Monkey logo

srt2hls's Introduction

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 2 SRT inputs on ports 10000 and 10001
  2. Create a production stream with basic logic between the 2 inputs
  3. Encode the stream in aac with 3 quality
  4. 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
sudo chown -R 10000:10001 hls
sudo docker-compose up

Local installation requirements

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 (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

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

srt2hls's People

Contributors

mbugeia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.