savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.42k stars 130 forks source link

SRT on Windows silently fails #2461

Open kpfa opened 2 years ago

kpfa commented 2 years ago

Describe the bug Running output.srt() on Windows exits with no log output, no audio sent.

To Reproduce caller.liq:

# Log Level
settings.server.log.level.set(5)
# Log to stdout
settings.log.stdout.set(true)
# Log level (SRT)
settings.srt.log.verbosity.set("debug")
# Route srt logs through liquidsoap's logs
settings.srt.log.set(true)

# SET ENV (select sound card) (found through Audacity)
setenv("PA_RECOMMENDED_INPUT_DEVICE","3")

# PCM 16bit stereo 48 kHz
settings.frame.audio.samplerate.set(48000)

# Assign Source (input PCM audio)
source = input(id="WHEATNET_INPUT_3")

# Output SRT (caller)
# Also tried with %wav(stereo=true, channels=2, samplesize=16, header=false), same result.

output.srt(
    host="192.168.10.199",
    port=9000,
    fallible=true,
    mode="caller",
    %ffmpeg(
      format="wav",
      %audio(
        codec="s16le",
        channels=2,
        samplerate=48000
        )
     ),
    source)

Runtime log:

.\liquidsoap.exe .\caller.liq                                         
2022/06/17 11:09:34 >>> LOG START                                                                                               
2022/06/17 11:09:33 [main:3] Liquidsoap 2.0.5                                                                                   
2022/06/17 11:09:33 [main:3] Using: bytes=[distributed with OCaml 4.02 or above] pcre=7.4.6 sedlex=2.2 menhirLib=20210929 dtools
=0.4.4 duppy=0.9.2 cry=0.6.6 mm=0.8.1 xmlplaylist=0.1.5 dynlink=[distributed with Ocaml] ffmpeg=1.1.2 ao=0.2.1 samplerate=0.1.6 
taglib=0.3.7 ssl=0.5.9 camomile=1.0.2 yojson=1.7.0 portaudio=0.2.3 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 winsvc=1.0.1                                                                                            
2022/06/17 11:09:33 [clock:3] Using builtin (low-precision) implementation for latency control                                  
2022/06/17 11:09:34 [frame:3] Using 48000Hz audio, 25Hz video, 48000Hz main.                                                    
2022/06/17 11:09:34 [frame:3] Video frame size set to: 1280x720                                                                 
2022/06/17 11:09:34 [frame:3] Frame size must be a multiple of 1920 ticks = 1920 audio samples = 1 video samples.               
2022/06/17 11:09:34 [frame:3] Targeting 'frame.duration': 0.04s = 1920 audio samples = 1920 ticks.                              
2022/06/17 11:09:34 [frame:3] Frames last 0.04s = 1920 audio samples = 1 video samples = 1920 ticks.                            
2022/06/17 11:09:34 [sandbox:3] Could not find binary bwrap, disabling sandboxing.                                              
2022/06/17 11:09:34 [video.converter:3] Using preferred video converter: ffmpeg.                                                
2022/06/17 11:09:34 [audio.converter:3] Using samplerate converter: ffmpeg.                                                     
2022/06/17 11:09:34 [clock.portaudio:3] Streaming loop starts in auto-sync mode                                                 
2022/06/17 11:09:34 [clock.portaudio:3] Delegating synchronisation to active sources                                            
2022/06/17 11:09:34 [video.add_text:3] Using native implementation                                                              
2022/06/17 11:09:34 [output.srt:3] Connecting to srt://192.168.10.199:9000..

Expected behavior output.srt to send audio to SRT receiver script running on remote host. Or error with a message.

Version details

Install method Binary from unzipped 2.0.5 release

toots commented 2 years ago

Thanks for this report. I don't think SRT has been tested a lot on windows, will have a look as soon as possible

kpfa commented 2 years ago

I wonder if this is an upstream issue with either libsrt or ffmpeg on windows? 🤷

The windows build of ffmpeg version 5.0.1-full_build-www.gyan.dev also silently fails by producing no output nor connection to our SRT listener.

.\ffmpeg.exe -f dshow -i audio="WNIP Input 3 (Wheatstone Netwo" -codec copy -f wav srt://192.168.10.199:9000

ffmpeg version 5.0.1-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enablemediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100

.... hits Ctrl+C ....  
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, dshow, from 'audio=WNIP Input  3 (Wheatstone Netwo':
  Duration: N/A, bitrate: N/A               
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
[srt @ 00000000003af1c0] Connection to srt://192.168.10.199:9000 failed: Immediate exit requested
srt://192.168.10.199:9000: Immediate exit requested
toots commented 2 years ago

Thanks for checking on that, that's interesting. How did you get the ffmpeg build?

toots commented 2 years ago

Are you running any firewall on your system? Any specific network configuration?

kpfa commented 2 years ago

The ffmpeg homepage has two external links for windows builds:

The Windows firewall is completely turned off. That was my first thought too!

There are a bit of network specifics here.

kpfa commented 2 years ago

Seems like https://github.com/savonet/liquidsoap/pull/2563 might fix this too?

toots commented 2 years ago

Hmm not sure. This PR enhances SRT support but I don't think it changes much. My guess would be to first get something minimal to work, maybe using ffmpeg or even better using libsrt examples binaries. Then, once we can confirm that it's supposed to work we can circle back here and see if the problem comes from something in the build.