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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

srt2hls's Issues

savonet/liquidsoap:latest not found

ERROR: Service 'liquidsoap' failed to build: manifest for savonet/liquidsoap:latest not found: manifest unknown: manifest unknown

Resolution:
update liquidsoap Dockerfile from savonet/liquidsoap:master to savonet/liquidsoap:main

Hls metadata

Хотелось бы увидеть от кого нибудь поддерждку hls metadata

I would like to see someone support hls metadata

docker-compose up returns with error

After checkout the last commit and run docker compose the next error appears:

E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/dists/buster/contrib/binary-amd64/by-hash/SHA256/bf331026669e460c3ac30a2311985f95ac1a1f23af17c2c2925eaeabe8dce3d9  File has unexpected size (13247 != 60848). Mirror sync in progress? [IP: 151.101.36.204 80]
   Hashes of expected file:
    - Filesize:60848 [weak]
    - SHA256:bf331026669e460c3ac30a2311985f95ac1a1f23af17c2c2925eaeabe8dce3d9
    - MD5Sum:f31383f923788c9cbdc8c30070a829a3 [weak]
   Release file created at: Sat, 16 Nov 2019 09:30:49 +0000
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/6f21fb3369b618a55bac745bff10835ac96ec1a7d8ec709029c7e9f0fa44ad25  
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/dists/buster/non-free/binary-amd64/by-hash/SHA256/b3907a55651abcdb1a96aea7c53b8ac8de072e0e3d4a0780422eb8049c78dcfe  
E: Failed to fetch http://cdn-fastly.deb.debian.org/debian/dists/buster-updates/main/binary-amd64/by-hash/SHA256/c53325539e311adc18245d580a0e297584641e26ddeec44f19e89023b3f3273d  File has unexpected size (13260 != 6292). Mirror sync in progress? [IP: 151.101.36.204 80]
   Hashes of expected file:
    - Filesize:6292 [weak]
    - SHA256:c53325539e311adc18245d580a0e297584641e26ddeec44f19e89023b3f3273d
   Release file created at: Fri, 13 Dec 2019 14:26:48 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service 'liquidsoap' failed to build: The command '/bin/sh -c echo " deb http://deb.debian.org/debian buster main contrib non-free\n deb http://security.debian.org/debian-security buster/updates main contrib non-free\n deb http://deb.debian.org/debian buster-updates main contrib non-free\n " > /etc/apt/sources.list     && apt-get update     && apt-get install -y        gnupg2        ca-certificates        dumb-init     && apt-key add /tmp/liquidsoap.key     && echo "deb http://deb.liquidsoap.info/debian stable main" > /etc/apt/sources.list.d/liquidsoap.list     && apt-get update     && apt-get install -y        liquidsoap-"$gitbranch"=1:"$version"-"$buildnumber"~stable     && rm -rf /var/lib/apt/lists/*     && groupadd -g 2000 radio     && useradd -m -u 2001 -g radio radio' returned a non-zero code: 100

Fatal error: exception FFmpeg.Avutils.Error(Encoder not found)

The latest docker-compose is throwing the following error on the liquidsoap container. First time launching this setup so haven't had it working before.

Haven't been able to start debugging yet but will do over the next few days, hoping it's something obvious to someone here! :)

Fatal error: exception FFmpeg.Avutils.Error(Encoder not found),
Raised by primitive operation at file "avcodec/avcodec.ml", line 129, characters 2-91,
Called from file "tools/utils.ml", line 25, characters 38-43,
Called from file "encoder/ffmpeg_encoder.ml", line 71, characters 4-75,
Called from file "encoder/ffmpeg_encoder.ml", line 229, characters 14-48,
Called from file "outputs/hls_output.ml", line 250, characters 8-63,
Called from file "list.ml", line 92, characters 20-23,
Called from file "outputs/hls_output.ml", line 294, characters 18-36,
Called from file "lang/lang.ml", line 384, characters 30-37,
Called from file "lang/lang_values.ml", line 1003, characters 12-18,
Called from file "lang/lang_values.ml", line 1079, characters 16-44,
Called from file "lang/lang.ml", line 597, characters 13-37,
Called from file "tools/tutils.ml", line 98, characters 12-16,
Re-raised at file "tools/tutils.ml", line 103, characters 4-11,
Called from file "lang/lang_errors.ml", line 66, characters 8-12,
Re-raised at file "lang/lang_errors.ml", line 161, characters 10-17,
Called from file "lang/lang.ml", line 617, characters 4-161,
Called from file "lang/lang.ml", line 624, characters 2-74,
Called from file "main.ml", line 124, characters 10-16,
Called from file "main.ml", line 662, characters 4-14,
Called from file "runner.ml", line 29, characters 14-32,
Line 364, char 15 before "### END Outputs":,
Error -1: Unknown error,
,
Fatal error: exception FFmpeg.Avutils.Error(Encoder not found),
Raised by primitive operation at file "avcodec/avcodec.ml", line 129, characters 2-91,
Called from file "tools/utils.ml", line 25, characters 38-43,
Called from file "encoder/ffmpeg_encoder.ml", line 71, characters 4-75,
Called from file "encoder/ffmpeg_encoder.ml", line 229, characters 14-48,
Called from file "outputs/hls_output.ml", line 250, characters 8-63,
Called from file "list.ml", line 92, characters 20-23,
Called from file "outputs/hls_output.ml", line 294, characters 18-36,
Called from file "lang/lang.ml", line 384, characters 30-37,
Called from file "lang/lang_values.ml", line 1003, characters 12-18,
Called from file "lang/lang_values.ml", line 1079, characters 16-44,
Called from file "lang/lang.ml", line 597, characters 13-37,
Called from file "tools/tutils.ml", line 98, characters 12-16,
Re-raised at file "tools/tutils.ml", line 103, characters 4-11,
Called from file "lang/lang_errors.ml", line 66, characters 8-12,
Re-raised at file "lang/lang_errors.ml", line 161, characters 10-17,
Called from file "lang/lang.ml", line 617, characters 4-161,
Called from file "lang/lang.ml", line 624, characters 2-74,
Called from file "main.ml", line 124, characters 10-16,
Called from file "main.ml", line 662, characters 4-14,
Called from file "runner.ml", line 29, characters 14-32,
Line 364, char 15 before "### END Outputs":,
Error -1: Unknown error,
,

Could you make a SRT to OBS?

Is there a way you could make a SRT server that can be played into OBS, with all of the SRT options available?

I want to send audio and video from android phone using "Larix Broadcaster" & the "h.265 (HEVC)" codec to an SRT server, then pull it into OBS Studio.

Kind Regards,
-b3ck

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.