voc/srtrelay

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

probablybenallen opened this issue · 4 comments

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 🎉

Curious about this - can you throw more detail in? I made a little widget (fragconsole) to autopull and play streams in hls.js, and I don't think I had to add a trailing slash. I basically convert to hls like so:

ffmpeg -y -i srt://some.srt.server:srtport?streamid=play/somestreamname -c:v libx264 -x264opts keyint=1:no-scenecut -s 640x360 -r 30 -b:v 900k -c:a aac -sws_flags bicubic -hls_time 1 -hls_list_size 60 -hls_delete_threshold 15 -hls_flags delete_segments stream_out_name_goes_here.m3u8

Sure thing!

So I'm now running some http auth middleware but srtrelay is complaining about the stream not existing so that shouldn't be an issue at this stage.

So I'm generating a test stream using this command:
ffmpeg -f lavfi -re -i testsrc=size=1920x1080:rate=25 -vf drawtext="fontfile=monofonto.ttf: fontsize=96: box=1: boxcolor=black@0.75: boxborderw=5: fontcolor=white: x=(w-text_w)/2: y=((h-text_h)/2)+((h-text_h)/4): text='%{localtime\:%X}'" -c:v libx264 -tune zerolatency -g 1 -b:v 20M -minrate 10M -maxrate 20M -bufsize 10M -an -strict -2 -y -bsf:v h264_mp4toannexb -f mpegts "srt://[IP_ADDRESS]:1935?streamid=publish/test/[PASSWORD]"

I then try receiving it using:
ffplay -fflags nobuffer -flags low_delay -framedrop -strict experimental "srt://[IP_ADDRESS]:1935?streamid=play/test"
and get from ffplay
srt://[IP_ADDRESS]:1935?streamid=play/test: I/O error f=0/0 nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

I change the command to:
ffplay -fflags nobuffer -flags low_delay -framedrop -strict experimental "srt://[IP_ADDRESS}:1935?streamid=play/test/"
and it works perfectly...

To see if I could understand it, I added some debugging lines into the Subscribe function that seemed to be producing the error in relay.go to show me the variable values at that time and it's quite weird - without the slash the channel name doesn't resolve. Below is the publisher connection, trying playing without the slash, the debug from that and then trying playing with a trailing slash

2021/02/21 21:02:03 [IP_ADDRESS]:49511 - publish test

name: test
channels: &{{1 0} map[test:0xc000076370] 0xc000052a78}
ok: false
channel: <nil>
get channel from map by var like code: <nil>

2021/02/21 21:02:07 [IP_ADDRESS]:49512 - Stream does not exist
2021/02/21 21:02:10 [IP_ADDRESS]:49513 - play test

Again I'm very new to go so it's entirely possible I've messed something obvious up, but as I was getting this bug with vanilla code I don't think this is a problem my config has added...?

Anything else u need let me know

Hi, so in theory this should be unrelated to your config. Playing with or without the slash should be the same (if the play is allowed, which it is in your case).

Could you try reproducing it with a different stream-name/different passwords? Do you maybe have some strange utf-8 characters in your string? Does the result change at all if you don't use http-auth?

At the time it affected all combinations of stream names and passwords only using standard 26 English alphabet characters.
But also appears to not be an issue anymore so will close, many thanks!