├── .gitignore ├── Dockerfile ├── README.md ├── docker-compose.yml └── sls.conf /.gitignore: -------------------------------------------------------------------------------- 1 | *.code-workspace 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # build stage 2 | FROM alpine:latest as build 3 | RUN apk update &&\ 4 | apk upgrade &&\ 5 | apk add --no-cache linux-headers alpine-sdk cmake tcl openssl-dev zlib-dev 6 | WORKDIR /tmp 7 | RUN git clone https://github.com/Edward-Wu/srt-live-server.git 8 | RUN git clone https://github.com/Haivision/srt.git 9 | WORKDIR /tmp/srt 10 | RUN ./configure && make && make install 11 | WORKDIR /tmp/srt-live-server 12 | RUN echo "#include "|cat - slscore/common.cpp > /tmp/out && mv /tmp/out slscore/common.cpp 13 | RUN make 14 | 15 | # final stage 16 | FROM alpine:latest 17 | ENV LD_LIBRARY_PATH /lib:/usr/lib:/usr/local/lib64 18 | RUN apk update &&\ 19 | apk upgrade &&\ 20 | apk add --no-cache openssl libstdc++ &&\ 21 | adduser -D srt &&\ 22 | mkdir /etc/sls /logs &&\ 23 | chown srt /logs 24 | COPY --from=build /usr/local/bin/srt-* /usr/local/bin/ 25 | COPY --from=build /usr/local/lib/libsrt* /usr/local/lib/ 26 | COPY --from=build /tmp/srt-live-server/bin/* /usr/local/bin/ 27 | COPY sls.conf /etc/sls/ 28 | VOLUME /logs 29 | EXPOSE 1935/udp 30 | USER srt 31 | WORKDIR /home/srt 32 | ENTRYPOINT [ "sls", "-c", "/etc/sls/sls.conf"] 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # srt-live-server 2 | Dockerized version of Edward Wu's SRT Live Server (SLS) and Haivision's SRT SDK 3 | All credit should go to the original tool author(s) - this is just a dockerization for convenience and portability. 4 | 5 | Requirements: 6 | * Docker 7 | * Access to Dockerhub, for either the prebuilt image or base layers 8 | 9 | To build: 10 | `docker build -t friendly_image_name_goes_here .` 11 | 12 | To run from dockerhub: 13 | `docker run -d -p 1935:1935/udp ravenium/srt-live-server` 14 | 15 | To run via docker-compose: 16 | `mkdir -p logs; chmod a+w logs; docker-compose up` 17 | 18 | Notes on the sls.conf (the config for srt-live-server) 19 | * Set port to default of 1935/UDP. Note that SRT doesn't technically have a default protocol port, so you will have to explicitly call this out in stream URLs (see below). 1935/TCP is what RTMP uses, so this makes it simpler to remember. 20 | * Set default latency to 200ms. (Nimble Streamer recommendeds no lower than 120ms no matter what, Haivision can do lower on hardware) If your streams are getting "confetti" you may want to set this higher, but I've found this to be a safe default in using OBS and Larix SRT streams over a reasonable internet connection. Think of this as a "safety buffer" for connection burps. 21 | * There are two "endpoints", a publisher and an application. Publishing is for sending, application is for recieving. They are "input/live" and "output/live", respectively - I changed them from the author's defaults to make them a bit less confusing. 22 | 23 | 24 | Example Sending of SRT in OBS: 25 | * In the setup menu under "stream", select "Custom..." leave the Key field blank. 26 | * Put the following url to send to your docker container: `srt://your.server.ip:1935?streamid=input/live/yourstreamname` 27 | 28 | Example of Receiving of SRT in OBS: 29 | * Add a Media Source 30 | * Put the following url to receive: `srt://your.server.ip:1935?streamid=output/live/yourstreamname` 31 | 32 | Errata, thoughts, future: 33 | * There are some things in the config that don't seem to work right yet, e.g. the on_event and status_url directives. If anyone gets these working, please let me know! 34 | * The container builds on the latest SRT SDK at build time (1.4.1 as of this writing) and srt-live-server (1.4.8) so try rebuilding the container if you need a new feature in either that isn't here yete. No guarantee future things won't break it. 35 | * You can map a docker volume so you can change your SLS config, then reload the container. Add the following to your docker run line: `-v /path/to/your/local/sls.conf:/etc/sls/sls.conf` 36 | * I'm looking for a way to monitor log output and parse the results for feed start/stop to make a stats server similar to nginx-rtmp, so if any bash/python/grep ninjas want to give it a whirl, please submit a PR! 37 | 38 | 39 | References: 40 | 41 | https://github.com/Edward-Wu/srt-live-server 42 | 43 | https://blog.wmspanel.com/2019/06/srt-latency-maxbw-efficient-usage.html 44 | 45 | https://www.haivision.com/blog/all/how-to-configure-srt-settings-video-encoder-optimal-performance/ 46 | 47 | 48 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | srt: 4 | image: ravenium/srt-live-server 5 | ports: 6 | - "1935:1935/udp" 7 | volumes: 8 | - ./sls.conf:/etc/sls/sls.conf 9 | - ./logs:/logs 10 | -------------------------------------------------------------------------------- /sls.conf: -------------------------------------------------------------------------------- 1 | srt { #SRT 2 | worker_threads 2; 3 | worker_connections 300; 4 | 5 | log_file /logs/error.log; 6 | log_level info; 7 | 8 | #stat_post_url http://192.168.31.106:8001/sls/stat; 9 | #stat_post_interval 5;#s 10 | 11 | #record_hls_path_prefix /tmp/mov/sls; 12 | #vod file name: /tmp/mov/sls/$listen/$domain_publisher/$app_publisher/$stream_name/vod.m3u8 13 | 14 | server { 15 | listen 1935; 16 | latency 200; #ms 17 | 18 | domain_player output; 19 | domain_publisher input; 20 | backlog 100; #accept connections at the same time 21 | idle_streams_timeout 60;#s -1: unlimited 22 | #on_event_url http://192.168.31.106:8000/sls/on_event; #?method=on_connect|on_close&role_name=&srt_url=%s 23 | app { 24 | app_player live ; 25 | app_publisher live ; 26 | 27 | #record_hls off;#on, off 28 | #record_hls_segment_duration 10; #unit s 29 | 30 | #relay { 31 | # type pull; 32 | # mode loop;#loop; hash; 33 | # reconnect_interval 10; 34 | # idle_streams_timeout -1;#s -1: unlimited 35 | # upstreams 127.0.0.1:9090?streamid=live.sls.com/live 192.168.1.100:8080/?streamid=live.test.com/live; 36 | #} 37 | #relay { 38 | # type push; 39 | # mode all; #all; hash 40 | # reconnect_interval 10; 41 | # idle_streams_timeout 10;#s -1: unlimited 42 | # upstreams 192.168.31.106:8080?streamid=uplive.sls.com/live ; 43 | #} 44 | } 45 | } 46 | } 47 | --------------------------------------------------------------------------------