liquidsoap icon indicating copy to clipboard operation
liquidsoap copied to clipboard

`input.srt(mode="caller")` fails to connect to `output.srt(mode="listener")`

Open nagisa opened this issue 1 year ago • 7 comments

Describe the bug

I have been attempting to set up a local network “radio” server, and I figured I would try out the SRT protocol, as recommended by the book. While I could get a basic

liquidsoap 'output(buffer(input.srt())); output.srt(%flac, sine())'
Logs
2022/10/01 15:35:39 >>> LOG START
2022/10/01 15:35:37 [main:3] Liquidsoap 2.0.6
2022/10/01 15:35:37 [main:3] Using: graphics=5.1.2 bytes=[distributed with OCaml 4.02 or above] posix-time2=2.0.0 pcre=7.4.6 sedlex=2.5 menhirLib=20220210 curl=0.9.2 dtools=0.4.4 duppy=0.9.2 cry=0.6.7 mm=0.8.1 xmlplaylist=0.1.5 lastfm=0.3.3 ogg=0.7.2 ogg.decoder=0.7.2 vorbis=0.8.0 vorbis.decoder=0.8.0 opus=0.2.2 opus.decoder=0.2.2 speex=0.4.1 speex.decoder=0.4.1 mad=0.5.2 flac=0.3.0 flac.ogg=0.3.0 flac.decoder=0.3.0 dynlink=[distributed with Ocaml] lame=0.3.6 shine=0.2.2 gstreamer=0.3.1 frei0r=0.1.2 fdkaac=0.3.2 theora=0.4.0 theora.decoder=0.4.0 ffmpeg=1.1.4 bjack=0.1.6 alsa=0.3.0 ao=0.2.4 samplerate=0.1.6 taglib=0.3.9 ssl=0.5.11 magic=0.7.3 camomile=1.0.2 inotify=2.3 yojson=2.0.2 faad=0.5.1 soundtouch=0.1.9 portaudio=0.2.3 pulseaudio=0.1.5 ladspa=0.2.2 dssi=0.1.5 lilv=0.1.0 tsdl=v0.9.8 tsdl-ttf=0.3.2 tsdl-image=0.3.2 camlimages=4.2.6 cohttp-lwt-unix=5.0.0 srt.constants=0.2.1 srt.types=0.2.1 srt.stubs=0.2.1 srt.stubs.locked=0.2.1 srt=0.2.1 lo=0.2.0 gd=1.0a5
2022/10/01 15:35:37 [gstreamer.loader:3] Loaded GStreamer 1.20.3 0
2022/10/01 15:35:37 [clock:3] Using native (high-precision) implementation for latency control
2022/10/01 15:35:39 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz main.
2022/10/01 15:35:39 [frame:3] Video frame size set to: 1280x720
2022/10/01 15:35:39 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.
2022/10/01 15:35:39 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks.
2022/10/01 15:35:39 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks.
2022/10/01 15:35:39 [sandbox:3] Could not find binary bwrap, disabling sandboxing.
2022/10/01 15:35:39 [video.converter:3] Using preferred video converter: ffmpeg.
2022/10/01 15:35:39 [audio.converter:3] Using samplerate converter: ffmpeg.
2022/10/01 15:35:39 [clock.pulseaudio:3] Streaming loop starts in auto-sync mode
2022/10/01 15:35:39 [clock.pulseaudio:3] Delegating synchronisation to CPU clock
2022/10/01 15:35:39 [clock.input.srt:3] Streaming loop starts in auto-sync mode
2022/10/01 15:35:39 [clock.input.srt:3] Delegating synchronisation to CPU clock
2022/10/01 15:35:39 [clock.main:3] Streaming loop starts in auto-sync mode
2022/10/01 15:35:39 [clock.main:3] Delegating synchronisation to CPU clock
2022/10/01 15:35:39 [output.srt:3] Connecting to srt://localhost:8000..
2022/10/01 15:35:39 [video.add_text:3] Using sdl implementation
2022/10/01 15:35:39 [output.srt:3] Client connected!

working just fine, I couldn’t get a reverse connection going – it outputs a huge number of messages saying it is unable to connect, before terminating the program.

To Reproduce

liquidsoap 'output(buffer(input.srt(mode="caller"))); output.srt(mode="listener", %flac, sine())'
Logs
2022/10/01 15:38:47 >>> LOG START
2022/10/01 15:38:46 [main:3] Liquidsoap 2.0.6
2022/10/01 15:38:46 [main:3] Using: graphics=5.1.2 bytes=[distributed with OCaml 4.02 or above] posix-time2=2.0.0 pcre=7.4.6 sedlex=2.5 menhirLib=20220210 curl=0.9.2 dtools=0.4.4 duppy=0.9.2 cry=0.6.7 mm=0.8.1 xmlplaylist=0.1.5 lastfm=0.3.3 ogg=0.7.2 ogg.decoder=0.7.2 vorbis=0.8.0 vorbis.decoder=0.8.0 opus=0.2.2 opus.decoder=0.2.2 speex=0.4.1 speex.decoder=0.4.1 mad=0.5.2 flac=0.3.0 flac.ogg=0.3.0 flac.decoder=0.3.0 dynlink=[distributed with Ocaml] lame=0.3.6 shine=0.2.2 gstreamer=0.3.1 frei0r=0.1.2 fdkaac=0.3.2 theora=0.4.0 theora.decoder=0.4.0 ffmpeg=1.1.4 bjack=0.1.6 alsa=0.3.0 ao=0.2.4 samplerate=0.1.6 taglib=0.3.9 ssl=0.5.11 magic=0.7.3 camomile=1.0.2 inotify=2.3 yojson=2.0.2 faad=0.5.1 soundtouch=0.1.9 portaudio=0.2.3 pulseaudio=0.1.5 ladspa=0.2.2 dssi=0.1.5 lilv=0.1.0 tsdl=v0.9.8 tsdl-ttf=0.3.2 tsdl-image=0.3.2 camlimages=4.2.6 cohttp-lwt-unix=5.0.0 srt.constants=0.2.1 srt.types=0.2.1 srt.stubs=0.2.1 srt.stubs.locked=0.2.1 srt=0.2.1 lo=0.2.0 gd=1.0a5
2022/10/01 15:38:46 [gstreamer.loader:3] Loaded GStreamer 1.20.3 0
2022/10/01 15:38:46 [clock:3] Using native (high-precision) implementation for latency control
2022/10/01 15:38:47 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz main.
2022/10/01 15:38:47 [frame:3] Video frame size set to: 1280x720
2022/10/01 15:38:47 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.
2022/10/01 15:38:47 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks.
2022/10/01 15:38:47 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks.
2022/10/01 15:38:47 [sandbox:3] Could not find binary bwrap, disabling sandboxing.
2022/10/01 15:38:47 [video.converter:3] Using preferred video converter: ffmpeg.
2022/10/01 15:38:47 [audio.converter:3] Using samplerate converter: ffmpeg.
2022/10/01 15:38:47 [clock.pulseaudio:3] Streaming loop starts in auto-sync mode
2022/10/01 15:38:47 [clock.pulseaudio:3] Delegating synchronisation to CPU clock
2022/10/01 15:38:47 [clock.input.srt:3] Streaming loop starts in auto-sync mode
2022/10/01 15:38:47 [clock.input.srt:3] Delegating synchronisation to CPU clock
2022/10/01 15:38:47 [clock.main:3] Streaming loop starts in auto-sync mode
2022/10/01 15:38:47 [clock.main:3] Delegating synchronisation to CPU clock
2022/10/01 15:38:47 [input.srt_0:3] Connecting to srt://localhost:8000..
2022/10/01 15:38:47 [video.add_text:3] Using sdl implementation
2022/10/01 15:38:47 [input.srt_0:3] Client connected!
2022/10/01 15:38:47 [pulse_out(liquidsoap:):3] Source failed (no more tracks) stopping output...
2022/10/01 15:38:48 [input.srt_0:2] Feeding failed: Avutil.Error(Generic error in an external library)
2022/10/01 15:38:48 [buffer.consumer_0:3] Source failed (no more tracks) stopping output...
2022/10/01 15:38:48 [input.srt_0:3] Connecting to srt://localhost:8000..
2022/10/01 15:38:48 [input.srt_0:3] Connect failed: Error(Econnrej,Connection setup failure: connection rejected)
<...repeated many times...>
2022/10/01 15:38:50 [input.srt_0:3] Connecting to srt://localhost:8000..
2022/10/01 15:38:50 [input.srt_0:3] Connect failed: Error(Econnrej,Connection setup failure: connection rejected)
2022/10/01 15:38:50 [input.srt_0:3] Connect failed: Not_found
<...repeated many times...>
2022/10/01 15:38:52 [input.srt_0:3] Connect failed: Not_found
2022/10/01 15:38:52 [input.srt_0:2] Feeding failed: Avutil.Error(Generic error in an external library)
2022/10/01 15:38:52 [clock.input.srt:2] Source buffer.consumer_0 failed while streaming: Too many open files in pipe()!
2022/10/01 15:38:52 [main:3] Shutdown started!
2022/10/01 15:38:52 [main:3] Waiting for main threads to terminate...
2022/10/01 15:38:52 [clock.input.srt:3] Streaming loop stopped.
2022/10/01 15:38:52 [clock.pulseaudio:3] Streaming loop stopped.
2022/10/01 15:38:52 [clock.main:3] Streaming loop stopped.
2022/10/01 15:38:52 [main:3] Main threads terminated.
2022/10/01 15:38:52 [threads:3] Shutting down scheduler...
2022/10/01 15:38:52 [threads:3] Scheduler shut down.
2022/10/01 15:38:54 [main:3] Cleaning downloaded files...
2022/10/01 15:38:54 [main:3] Freeing memory...

Expected behavior

The second command should output a sine wave to the headphones, much like the1 first command.

Version details

  • OS: NixOS
  • Version: 2.0.6

Install method

OPAM

Common issues

Can't decode or encode in some audio format? Check if you have installed the correct dependencies

nagisa avatar Oct 01 '22 12:10 nagisa

Verified reproducible with 2.1.2 as well.

2022/10/01 19:35:37 [main:3] Liquidsoap 2.1.2
2022/10/01 19:35:37 [main:3] Using: graphics=5.1.2 bytes=[distributed with OCaml 4.02 or above] posix-time2=2.0.0 pcre=7.5.0 sedlex=2.5 menhirLib=20220210 curl=0.9.2 uri=4.2.0 dtools=0.4.4 duppy=0.9.2 cry=0.6.7 mm=0.8.1 xmlplaylist=0.1.5 lastfm=0.3.3 ogg=0.7.3 ogg.decoder=0.7.3 vorbis=0.8.0 vorbis.decoder=0.8.0 opus=0.2.2 opus.decoder=0.2.2 speex=0.4.1 speex.decoder=0.4.1 mad=0.5.2 flac=0.3.0 flac.ogg=0.3.0 flac.decoder=0.3.0 dynlink=[distributed with Ocaml] lame=0.3.6 shine=0.2.2 gstreamer=0.3.1 frei0r=0.1.2 fdkaac=0.3.2 theora=0.4.0 theora.decoder=0.4.0 ffmpeg=1.1.6 bjack=0.1.6 alsa=0.3.0 ao=0.2.4 samplerate=0.1.6 taglib=0.3.10 ssl=0.5.11 magic=0.7.3 camomile=1.0.2 inotify=2.3 faad=0.5.1 soundtouch=0.1.9 portaudio=0.2.3 pulseaudio=0.1.5 ladspa=0.2.2 dssi=0.1.5 lilv=0.1.0 tsdl=v0.9.8 tsdl-ttf=0.3.2 tsdl-image=0.3.2 camlimages=4.2.6 camlimages.freetype=5.0.4 cohttp-lwt-unix=5.0.0 srt.constants=0.2.1 srt.types=0.2.1 srt.stubs=0.2.1 srt.stubs.locked=0.2.1 srt=0.2.1 lo=0.2.0 gd=1.0a5

nagisa avatar Oct 01 '22 16:10 nagisa

I’ve done some additional investigation using gstreamer as a client/server and looking at wireshark.

First, with liquidsoap as both a server & client, wireshark displays a bunch of UDT handshake traffic, so connectivity is there, but the handshake seems to be failing.

With

liquidsoap 'output.srt(mode="listener", %flac, sine())'
gst-launch-1.0 srtsrc mode=caller uri="srt://127.0.0.1:8000" ! fakesink

The handshake succeeds, and the connection stays idle (sending some keep-alives around, no actual data).

With

gst-launch-1.0 audiotestsrc ! flacenc ! srtsink mode=listener localaddress=127.0.0.1 localport=8000
liquidsoap 'output(buffer(input.srt(mode="caller")))'

I see a successfully established connection and the data is moving around too. There isn’t any sound, but I suspect that’s probably largely just because data is not getting automatically decoded on the liquidsoap end.

So, if I had to put blame on something, it’d be on output.srt in listener mode misbehaving in some way.

nagisa avatar Oct 01 '22 17:10 nagisa

Thanks for reporting. This seems to be working. Streams decoding defaults to the ffmpeg decoder. Do you have the ffmpeg binding installed as well? If not, try to do: opam install ffmpeg and try again.

toots avatar Oct 04 '22 01:10 toots

Thanks for reporting. This seems to be working. Streams decoding defaults to the ffmpeg decoder. Do you have the ffmpeg binding installed as well? If not, try to do: opam install ffmpeg and try again.

toots avatar Oct 04 '22 01:10 toots

Yeah, I’ve the ffmpeg package (tried both 1.1.4 & 1.1.6.) ffmpeg itself is at version 4.4.2.

nagisa avatar Oct 05 '22 18:10 nagisa

Addendum to https://github.com/savonet/liquidsoap/issues/2661#issuecomment-1264434927:

gst-launch-1.0 audiotestsrc ! flacenc ! oggmux ! srtsink mode=listener localaddress=127.0.0.1 localport=8000
liquidsoap 'output(buffer(input.srt(mode="caller")))'

works alright (the flac has been muxed into an ogg for streaming purposes)

liquidsoap 'output.srt(mode="listener",  %ogg(%flac), sine()); output(buffer(input.srt(mode="caller")))'

still fails the same way as reported originally.

nagisa avatar Oct 05 '22 18:10 nagisa

I can reproduce your error with 2.1.2 indeed. The error is fixed in main, it works with the %mp3 format. However, there's another issue there with %ogg(%flac) due to some on-going data format changes that will be resolved once we finish the migration to generic and immutable content.

For now, I'd suggest to stick with gstreamer until this is fixed. Thanks for your report and patience.

toots avatar Oct 11 '22 14:10 toots