Git Product home page Git Product logo

srtrelay's Introduction

srtrelay CI

Streaming-Relay for the SRT-protocol

Use at your own risk.

Quick start

Run with docker (Note: nightly image not recommended for production)

docker run ghcr.io/voc/srtrelay/srtrelay:latest

# start publisher
ffmpeg -i test.mp4 -c copy -f mpegts srt://localhost:1337?streamid=publish/test

# start subscriber
ffplay -fflags nobuffer srt://localhost:1337?streamid=play/test

Start docker with custom config. See config.toml.example

# provide your own config from the local directory
docker run -v $(pwd)/config.toml:/home/srtrelay/config.toml ghcr.io/voc/srtrelay/srtrelay:latest

Run with docker-compose

In your docker-compose.yml:

   srtrelay:
     image: ghcr.io/voc/srtrelay/srtrelay:latest
     restart: always
     container_name: srtrelay
     volumes:
       - ./srtrelay-config.toml:/home/srtrelay/config.toml
     ports:
       - "44560:1337/udp"

This will forward port 44560 to internal port 1337 in the container. Importantly, forwarding UDP is required. It will also copy a srtrelay-config.toml file in the same directory into the container to use as config.toml

Start the server with the usual

docker-compose up -d

Build with docker

You will need atleast docker-20.10

docker build -t srtrelay .

# run srtrelay
docker run --rm -it srtrelay

Build without docker

Install Dependencies

Requires >=libsrt-1.4.2, golang and a C compiler

Ubuntu

Debian 10:

Gentoo:

  • emerge net-libs/srt

Build

go build -o srtrelay

# run srtrelay
./srtrelay

Usage

Commandline Flags

# List available flags
./srtrelay -h

Configuration

Please take a look at config.toml.example to learn more about configuring srtrelay.

The configuration file can be placed under config.toml in the current working directory, at /etc/srtrelay/config.toml or at a custom location specified via the -config flag.

API

See docs/API.md for more information about the API.

Contributing

See docs/Contributing.md

Credits

Thanks go to

srtrelay's People

Contributors

derchrisuk avatar fu5ha avatar garionion avatar ischluff avatar jankoppe avatar kevmo314 avatar ravenium avatar stvmyr 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

srtrelay's Issues

http-auth x509: certificate signed by unknown authority

2023/11/26 02:04:38 http-auth: Post "https://example.com/broadcast/srt/authorize/": x509: certificate signed by unknown authority
2023/11/26 02:04:38 8.8.8.8:58886 - Stream 'publish/awmusic12635' access denied
02:04:38.147595/SRT:RcvQ:w1!W:SRT.cn: @923775032:newConnection: connection rejected due to: INTERNAL REJECTION - ERROR:PREDEFINED:401
02:04:38.148049/SRT:RcvQ:w1!W:SRT.cn: processConnectRequest: rsp(REJECT): 2401 - Application-defined rejection reason

Having a situation where the http-auth is rejecting even querying my auth URL due to it not knowing the SSL cert. The domain is using a Let's encrypt cert that works on all other situations I've seen (on the host, in the browser etc).

I cannot disable https on the domain

Is there a way this can be made to be trusted or at the very minimum a way to allow insecure certificates?

Abnormal program termination with lossy stream publisher

Hello, first off this is a great piece of software, works very nicely in my testing. I wanted to report one issue I saw, not sure if this is within the libsrt library or the srtrelay app, but when publishing a stream with a severely lossy connection, the program exited abnormally. Below are a few logfiles from the end of the terminal.

23:54:04.089735/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 9 packet(s). Packet seqno %194915974 delayed for 0.210 ms
23:54:04.095921/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 9 packet(s). Packet seqno %194915984 delayed for 6.360 ms
23:54:04.098852/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 16 packet(s). Packet seqno %194916002 delayed for 9.214 ms
23:54:04.101323/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 9 packet(s). Packet seqno %194916013 delayed for 11.643 ms
23:54:04.136888/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 12 packet(s). Packet seqno %194916026 delayed for 2.510 ms
23:54:04.137017/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 7 packet(s). Packet seqno %194916042 delayed for 2.075 ms
23:54:04.146945/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 2 packet(s). Packet seqno %194916059 delayed for 11.648 ms
23:54:04.175223/SRT:TsbPd!W:SRT.br: @223707369:RCV-DROPPED 12 packet(s). Packet seqno %194916091 delayed for 0.592 ms
terminate called after throwing an instance of 'std::runtime_error'
  what():  FixedArray: invalid index
Aborted

If I should provide any additional information to help track down the problem, I would be happy to do this. Thanks!

Error in srt_bind

Hello, I'm trying to start the srtrelay server using Docker Compose, but I keep encountering the following error. Where could the issue be? I would appreciate any help.

Listen failed for xxx.xxx.xxx.xxx:1337 : Error in srt_bind: An error occurred when trying to call a system function on an internally used UDP socket

Exporting socket stats

One feature in SLS that was present was the ability to export the SRT socket's stats. Actually, I'd be willing to contribute this too as the feature seems relatively simple. I'd be happy to send a PR, but wanted to make sure the implementation aligns with what you expect and there isn't any work already being done?

I would implement it as basically for every socket connection, periodically get the stats and POST it to an HTTP endpoint specified in the config.

Relay Push mode

This is amazing, i am trying it today for the first time. I came here looking for a relay push mode to experiment with. I am wondering if there is a way to achieve this with srtrelay. Is there a feature, similar to sls, where you can specify a relay type push method to push it to another srtrelay node?

This is fantastic btw, thank you. Testing now.

/play/* uri needs trailing slash after channel name or playback doesn't work (/play/*/)

Very minor thing, I'm not sure if this is my webserver config, FFmpeg or srtreplay, but I need to add a trailing slash to the play URI or the server can't find the stream. Took me a while to debug purely by dumb luck (I'm very new to go).

This is different from the publish URI which works with and without a trailing slash. This only seems to affect play...

(My config has auth unchanged from the default if that helps)

This project looks awesome!! Finally the Nginx RTMP module replacement I've wanted for ages 🎉

Renaming StreamIDs on the fly (another nginx-RTMP feature)

This was recently pointed out to me as A Thing, but it might only natively be an RTMP Thing. :)

Apparently it's possible to 302 redirect RTMP streams to a new stream name in nginx-rtmp, for example, if you connect as /live/mystream, nginx-rtmp redirects you to /live/mystream_12345 for publishing. This in effect lets you publish multiple times with the same stream name as it renames itself to avoid namespace collisions:

https://stackoverflow.com/questions/43568168/how-to-change-nginx-rtmp-stream-name-after-call-on-publish

Any idea if this could be implemented in SRT? It wouldn't be hard to generate a new StreamID on the fly, but my understanding of the SRT SDK seems to suggest that StreamID is embedded into the publish stream and is immutable on the protocol level.

Listener's backlog exceeded error

Seeing this error in v1.2.0 after upgrading. Server will work normal for a few minutes and then all streams will stop working and new client caller connections will fail with Listener's backlog exceeded and the server log will repeat it constantly. v1.1.0 has worked perfectly in this same environment.

Environment, if it helps in narrowing down the issue

  • 2 live stream publishers
  • 1 client caller playing each published video
  • ~100 client caller's attempting to connect to non-existent streams repeatedly <name> - stream does not exist
  • auth.http URL being used to authenticate connections

image

HEVC Parsing

Does anyone get HEVC SRT working with srtrelay? Do we have to implement a new parser in GO for this project?

Thx.

Vmix Support

Does this have srt support for vmix? If not are there plans to implement it later in the future?

Sockets not always loaded

API-sockets (server:port/sockets) are not always loaded, and page just returns completely blank page (200 OK). Nothing explains in log.

This seems to happen in case of multiple subscribers (players).

In my case, tested with 1 publisher, and 5 players. (It do happen with 4 playing streams as well, but not always)

v.1.1.0

Change 'publish' to 'publisher'?

Is it possible to change 'publish' to 'publisher' in any easy way, without having to re-build everything?
(Like: publish/test to publisher/test)

Its only be course i'm looking into changing SRT-server and the old one im using, is using 'publisher', and there is quite a lot of people using my server, that needs to make that change in URL if I switch to srtrelay.

Best Regards.

docker-proxy & IPv6: weird errors in the log

I'm seeing some weird issue, not sure if this is the fault of Docker or the SRT lib. When running a container with port forwarding on Docker 20.10.8, I'm seeing some weird errors in the logs for IPv6 connections. IPv4 (the first connection in the log) actually works great, and even sees the true client IP. When connecting with IPv6, apparently, the SRT lib falls on its nose while decoding the Client IP. It then falls back to the internal gateway IP of the Docker network. This seems only cosmetic - the data still arrives fine.

Logs:

srtrelay_1  | 2021/09/11 07:55:17 Read config from config.toml
srtrelay_1  | 2021/09/11 07:55:17 SRT Listening on :::20000
srtrelay_1  | 2021/09/11 07:55:17 API listening on :8080
srtrelay_1  | 2021/09/11 07:55:33 213.240.**.**:36586 - publish foo
srtrelay_1  | 2021/09/11 07:58:22 213.240.**.**:36586 - foo - The socket has been closed
srtrelay_1  | 2021/09/11 07:58:22 Removing stream foo
srtrelay_1  | 08:00:20.088221/SRT:RcvQ:w1*E:SRT.in: pton: IPE or net error: can't determine IPv4 carryover format: 12a:f804:**:**:0:0:0:200
srtrelay_1  | 08:00:20.088637/SRT:RcvQ:w1*E:SRT.in: pton: IPE or net error: can't determine IPv4 carryover format: 12a:f804:**:**:0:0:0:200
srtrelay_1  | 2021/09/11 08:00:20 172.20.0.1:50787 - publish foo
srtrelay_1  | 2021/09/11 08:01:51 172.20.0.1:50787 - foo - The socket has been closed

docker-compose.yaml:

version: '3.8'

services:
  srtrelay:
    image: ghcr.io/voc/srtrelay/srtrelay:latest
    volumes:
      - ./srtrelay.toml:/home/srtrelay/config.toml:ro
    ports:
      - 20000:20000/udp
# ss -ulpn
State   Recv-Q  Send-Q   Local Address:Port    Peer Address:Port  Process
UNCONN  0       0              0.0.0.0:20000        0.0.0.0:*      users:(("docker-proxy",pid=338418,fd=4))
UNCONN  0       0                 [::]:20000           [::]:*      users:(("docker-proxy",pid=338425,fd=4))

Features: Adding config support, streamID filtering via URL or slice

Hello! First off, thank you so much for writing this - my golang probably wasn't up to the challenge of properly utilizing the srtgo bindings.

I've forked and added some basic support for configs (viper) and a few filtering mechanisms based on our needs (streaming aggregation for twitch across sites). I can submit a PR but figured I'd check in first.

Error on running srtrelay

Hello,

srtrelay is giving error while trying to run.

./srtrelay: error while loading shared libraries: libsrt.so.1.4: cannot open shared object file: No such file or directory

Stream quality problems

We using IRL LibeU Solo with the SRT transmit. I setup a docker image in OVH to relay to my production OBS.

But the stream quality is very bad. Lots of glitching and black out - as if its loosing the GOP? I blamed them for it but I setup a direct to studio SRT connection and the stream is perfect.

What could be causing this issue?

Bad stream quality with high RTT

rtt在150到200左右,推送花屏挺多,有啥参数可以控制吗,另外ffmpeg拉中继流转推flv经常出现

[flv @ 0x3753080] Error applying bitstream filters to an output packet for stream #1: Invalid data found when processing input
av_interleaved_write_frame(): Invalid data found when processing input

Translation:
The rtt is around 150 to 200, and there are quite a lot of blurry frames. Is there any parameter that can be controlled? In addition, ffmpeg pulls the relay stream and pushes the flv frequently.

'synchronize MPEG-TS clients to a GOP start' for h265?

The 'synchronize MPEG-TS clients to a GOP start' seems to fix some issues I have, when OBS is connecting to an SRT-server. The sound becomes laggy from time to time. You guys seems to have fixed that.

Is there any timeframe for fixing this for the h265 as well? Or is there any other workaround until then?

Best regards.

http auth rejected

Im running this in Kubernetes, and calling a NodeJS endpoint for auth. The auth endpoint is one already used for nginx-rtmp. It does not appear that srtrelay is actually calling the auth enpoint at all (i have logging when the endpoint is called). When i curl the auth url, it acts as expected.

Logs:
2022/07/15 01:46:36 10.108.0.4:15986 - Stream 'publish/test/testy' access denied 01:46:36.966059/SRT:RcvQ:w1!W:SRT.cn: @242378928:newConnection: connection rejected due to: INTERNAL REJECTION - ERROR:PREDEFINED:401 01:46:36.966194/SRT:RcvQ:w1!W:SRT.cn: processConnectRequest: rsp(REJECT): 2401 - Application-defined rejection reason

Any idea why my auth endpoint might not be called? Thank you for the help!

[ enhancement ] Supports SRT Access Control streamid with recomended format

srtdelay way use for streamid the syntaxt:
(play|publish)/(stream-key)[/password]

It would be recommended if srtdelay could also support the access control methods as defined in the SRT
https://github.com/Haivision/srt/blob/master/docs/features/access-control.md

#!::m=(request|publish),r=(stream-key),u=(user),s=(password)

with your example:

# start publisher
ffmpeg -i test.mp4 -c copy -f mpegts 'srt://localhost:1337?streamid=#!::m=publish,r=test'
# start subscriber
ffplay -fflags nobuffer 'srt://localhost:1337?streamid=#!::m=request,r=test'

Some new hardware equipment comes prepared for use this type of syntax.

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.