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.4k stars 128 forks source link

Unknown Track Title while using multiple fallbacks with input.harbor and crossfade #2138

Closed TheRealMattLear closed 2 years ago

TheRealMattLear commented 2 years ago

Describe the bug

We use multiple input.harbors in a fallback to prioritise encoder input but I'm seeing an issue with liquidsoap 2.0.2 while using multiple fallback()'s and input.harbor. I've been able to minimise our script to reproduce the problem.

a) If i remove the defaultDJ = fallback line then everything works normally. b) If i remove only the radio = crossfade then the metadata is not sent to the icecast server at all, and the previous track (Ed Sheeran) remains in now playing.

To Reproduce

settings.request.metadata_decoders.set(["TAGLIB", "FLAC", "OGG"])

# Add Skip to Playouts
playoutGroup = fallback(id="Playout Group", track_sensitive=false, [single("/usr/local/mediacp/content/user_15/music/Ed Sheeran/03 - Dive.mp3")]);

defaultDj = input.harbor(id="/", port=6800, buffer=11.0, max=30.0, log_overfull = false, icy=true, password="THCqeF6ZDUn3", auth=fun(_) -> begin true; end, "");

# Following line triggers unknown on initial harbor connection,
# or if no crossfade, the meta data is not updated on initial connection
defaultDj = fallback(track_sensitive=false,[defaultDj]);

radio = fallback(track_sensitive=false,[defaultDj, playoutGroup])

# Crossfade here causes unknown, comment out
radio = crossfade(smart=false, duration=5.00,fade_out=2.00,fade_in=3.00,radio)

radio = mksafe(radio)

    output.icecast(

        %fdkaac(channels=2,samplerate=44100,bitrate=128,afterburner=true,aot="mpeg4_aac_lc",transmux="adts",sbr_mode=false),
        mount = "/stream",host = "127.0.0.1",port = 8000,password = "THCqeF6ZDUn3",encoding = "UTF-8",

        name = "",description = "",url = "",genre = "",public = true,
        icy_metadata = "true",

        radio
    );

Output from liquidsoap

2022/01/01 17:55:34 >>> LOG START
2022/01/01 17:55:33 [main:3] Liquidsoap 2.0.2
2022/01/01 17:55:33 [main:3] Using: bytes=[distributed with OCaml 4.02 or above] pcre=7.4.6 sedlex=2.2 menhirLib=20211128 curl=0.9.1 dtools=0.4.4 duppy=0.9.2 cry=0.6.5 mm=0.7.2 ogg=0.7.0 ogg.decoder=0.7.0 vorbis=0.8.0 vorbis.decoder=0.8.0 opus=0.2.0 opus.decoder=0.2.0 mad=0.5.0 flac=0.3.0 flac.ogg=0.3.0 flac.decoder=0.3.0 dynlink=[distributed with Ocaml] lame=0.3.5 fdkaac=0.3.2 theora=0.4.0 theora.decoder=0.4.0 ffmpeg=1.1.1 samplerate=0.1.6 taglib=0.3.7 ssl=0.5.9 camomile=1.0.2 faad=0.5.0 ladspa=0.2.0
2022/01/01 17:55:33 [clock:3] Using builtin (low-precision) implementation for latency control
2022/01/01 17:55:34 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz main.
2022/01/01 17:55:34 [frame:3] Video frame size set to: 1280x720
2022/01/01 17:55:34 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.
2022/01/01 17:55:34 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks.
2022/01/01 17:55:34 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks.
2022/01/01 17:55:34 [sandbox:3] Sandboxing disabled
2022/01/01 17:55:34 [video.converter:3] Using preferred video converter: ffmpeg.
2022/01/01 17:55:34 [audio.converter:3] Using samplerate converter: ffmpeg.
2022/01/01 17:55:34 [harbor:3] Adding mountpoint '/' on port 6800
2022/01/01 17:55:34 [single_0:3] /usr/local/mediacp/content/user_15/music/Ed Sheeran/03 - Dive.mp3 is static, resolving once for all...
2022/01/01 17:55:34 [single_0:3] Prepared "/usr/local/mediacp/content/user_15/music/Ed Sheeran/03 - Dive.mp3" (RID 0).
2022/01/01 17:55:34 [output.icecast_0:3] Connecting mount /stream for source@127.0.0.1...
2022/01/01 17:55:34 [output.icecast_0:3] Connection setup was successful.
2022/01/01 17:55:34 [clock.main:3] Streaming loop starts in auto-sync mode
2022/01/01 17:55:34 [clock.main:3] Delegating synchronisation to CPU clock
2022/01/01 17:55:34 [mksafe:3] Switch to crossfade_0.
2022/01/01 17:55:34 [switch_2:3] Switch to Playout_Group.
[mp3float @ 0x7fd47c006400] Could not update timestamps for skipped samples.
2022/01/01 17:55:34 [Playout_Group:3] Switch to single_0.
2022/01/01 17:55:39 [/:3] Decoding...
2022/01/01 17:55:39 [/:3] New metadata chunk ? -- Aerosmith - I Don't Want to Miss a Thing.
2022/01/01 17:55:50 [switch_2:3] Switch to switch_1 with transition.
2022/01/01 17:55:50 [switch_1:3] Switch to /.
2022/01/01 17:55:50 [crossfade_0:3] Analysis: -20.147236dB / -25.717562dB (4.96s / 4.96s)
2022/01/01 17:55:50 [crossfade_0:3] Simple transition: crossed, fade-in, fade-out.

Expected behavior When the harbor.input takes over, the meta passed through should be immedately sent to the icecast server

Version details

Packages installed

# Packages matching: installed
# Name                  # Installed # Synopsis
base-bigarray           base
base-bytes              base        Bytes library distributed with the OCaml compiler
base-threads            base
base-unix               base
camomile                1.0.2       A Unicode library
conf-autoconf           0.1         Virtual package relying on autoconf installation
conf-automake           1           Virtual package relying on GNU automake
conf-ffmpeg             1           Virtual package relying on FFmpeg
conf-ladspa             1           Virtual package relying on ladspa
conf-lame               1           Virtual package relying on lame
conf-libcurl            1           Virtual package relying on a libcurl system installation
conf-libflac            1           Virtual package relying on libFLAC
conf-libogg             1           Virtual package relying on libogg
conf-libopus            1           Virtual package relying on libopus
conf-libpcre            1           Virtual package relying on a libpcre system installation
conf-libssl             3           Virtual package relying on an OpenSSL library system installation
conf-libtheora          1           Virtual package relying on libtheora
conf-libvorbis          1           Virtual package relying on libvorbis
conf-m4                 1           Virtual package relying on m4
conf-pkg-config         2           Check if pkg-config is installed and create an opam switch local pkgconfig folder
conf-samplerate         1           Virtual package relying on samplerate
conf-taglib             1           Virtual package relying on taglib
conf-which              1           Virtual package relying on which
cry                     0.6.5       OCaml client for the various icecast & shoutcast source protocols
csexp                   1.5.1       Parsing and printing of S-expressions in Canonical form
dtools                  0.4.4       Library providing various helper functions to make daemons
dune                    2.9.1       Fast, portable, and opinionated build system
dune-configurator       2.9.1       Helper library for gathering system configuration
duppy                   0.9.2       Library providing monadic threads
faad                    0.5.0       Bindings for the faad library which provides functions for decoding AAC audio files
fdkaac                  0.3.2       Fraunhofer FDK AAC Codec Library
ffmpeg                  1.1.1       Bindings for the ffmpeg libraries
ffmpeg-av               1.1.1       Bindings for the ffmpeg libraries -- top-level helpers
ffmpeg-avcodec          1.1.1       Bindings for the ffmpeg avcodec library
ffmpeg-avdevice         1.1.1       Bindings for the ffmpeg avdevice library
ffmpeg-avfilter         1.1.1       Bindings for the ffmpeg avfilter library
ffmpeg-avutil           1.1.1       Bindings for the ffmpeg avutil libraries
ffmpeg-swresample       1.1.1       Bindings for the ffmpeg swresample library
ffmpeg-swscale          1.1.1       Bindings for the ffmpeg swscale library
flac                    0.3.0       Bindings to libflac
gen                     0.5.3       Iterators for OCaml, both restartable and consumable
ladspa                  0.2.0       Bindings for the LADSPA API which provides audio effects
lame                    0.3.5       MP3 encoding library
liquidsoap              2.0.2       pinned to version 2.0.2 at git+file:///usr/local/mediacp/liquidsoap/source#HEAD
mad                     0.5.0       Mad decoding library
menhir                  20211128    An LR(1) parser generator
menhirLib               20211128    Runtime support library for parsers generated by Menhir
menhirSdk               20211128    Compile-time library for auxiliary tools related to Menhir
mm                      0.7.2       The mm library contains high-level to create and manipulate multimedia streams (audio, video, MIDI)
ocaml                   4.08.1      The OCaml compiler (virtual package)
ocaml-base-compiler     4.08.1      Official release 4.08.1
ocaml-config            1           OCaml Switch Configuration
ocaml-migrate-parsetree 1.8.0       Convert OCaml parsetrees between different versions
ocamlbuild              0.14.0      OCamlbuild is a build system with builtin rules to easily build most OCaml projects.
ocamlfind               1.9.1       A library manager for OCaml
ocurl                   0.9.1       Bindings to libcurl
ogg                     0.7.0       Bindings to libogg
opam-depext             1.2.0       Install OS distribution packages
opus                    0.2.0       Bindings to libopus
pcre                    7.4.6       Bindings to the Perl Compatibility Regular Expressions library
ppx_derivers            1.2.1       Shared [@@deriving] plugin registry
ppx_tools_versioned     5.4.0       A variant of ppx_tools based on ocaml-migrate-parsetree
result                  1.5         Compatibility Result module
samplerate              0.1.6       Samplerate audio conversion library
sedlex                  2.2         An OCaml lexer generator for Unicode
ssl                     0.5.10      Bindings for OpenSSL
taglib                  0.3.7       Bindings for the taglib library
theora                  0.4.0       Bindings to libtheora
uchar                   0.0.2       Compatibility library for OCaml's Uchar module
vorbis                  0.8.0       Bindings to libvorbis
TheRealMattLear commented 2 years ago

Hi, is there anything else i can do that would be helpful to the investigation? We have quite a number of users with the problem and i'm wondering could we do something better in our scripting or is there a bug here?

toots commented 2 years ago

Thanks for this report and the minimized script. I'll have a look this week.

toots commented 2 years ago

I can confirm and reproduce the issue.

TheRealMattLear commented 2 years ago

Thanks @toots appreciate your time, i'm happy to test any commit for you also.

toots commented 2 years ago

I was able to fix the provided example. Could you test with either the latest main or from the new v2.0.3-preview branch? Thanks!

TheRealMattLear commented 2 years ago

@toots hitting an error on this branch, could it be due to opam/ocaml version?

# sudo -u mediacp /usr/local/mediacp/liquidsoap/bin/liquidsoap ./liquidsoap.liq
At /usr/local/mediacp/.opam/4.08.1/lib/liquidsoap/share/liquidsoap/git/ecbcf72e/libs/playlist.liq, line 56, char 8-16:
        list.map.right(file_request, files)

Error 5: this value has no method right

opam list

# Name                  # Installed # Synopsis
base-bigarray           base
base-bytes              base        Bytes library distributed with the OCaml compiler
base-threads            base
base-unix               base
camomile                1.0.2       A Unicode library
conf-autoconf           0.1         Virtual package relying on autoconf installation
conf-automake           1           Virtual package relying on GNU automake
conf-ffmpeg             1           Virtual package relying on FFmpeg
conf-ladspa             1           Virtual package relying on ladspa
conf-lame               1           Virtual package relying on lame
conf-libcurl            1           Virtual package relying on a libcurl system installation
conf-libflac            1           Virtual package relying on libFLAC
conf-libogg             1           Virtual package relying on libogg
conf-libopus            1           Virtual package relying on libopus
conf-libpcre            1           Virtual package relying on a libpcre system installation
conf-libssl             3           Virtual package relying on an OpenSSL library system installation
conf-libtheora          1           Virtual package relying on libtheora
conf-libvorbis          1           Virtual package relying on libvorbis
conf-m4                 1           Virtual package relying on m4
conf-pkg-config         2           Check if pkg-config is installed and create an opam switch local pkgconfig folder
conf-samplerate         1           Virtual package relying on samplerate
conf-taglib             1           Virtual package relying on taglib
conf-which              1           Virtual package relying on which
cry                     0.6.5       OCaml client for the various icecast & shoutcast source protocols
csexp                   1.5.1       Parsing and printing of S-expressions in Canonical form
dtools                  0.4.4       Library providing various helper functions to make daemons
dune                    2.9.1       Fast, portable, and opinionated build system
dune-configurator       2.9.1       Helper library for gathering system configuration
duppy                   0.9.2       Library providing monadic threads
faad                    0.5.0       Bindings for the faad library which provides functions for decoding AAC audio files
fdkaac                  0.3.2       Fraunhofer FDK AAC Codec Library
ffmpeg                  1.1.1       Bindings for the ffmpeg libraries
ffmpeg-av               1.1.1       Bindings for the ffmpeg libraries -- top-level helpers
ffmpeg-avcodec          1.1.1       Bindings for the ffmpeg avcodec library
ffmpeg-avdevice         1.1.1       Bindings for the ffmpeg avdevice library
ffmpeg-avfilter         1.1.1       Bindings for the ffmpeg avfilter library
ffmpeg-avutil           1.1.1       Bindings for the ffmpeg avutil libraries
ffmpeg-swresample       1.1.1       Bindings for the ffmpeg swresample library
ffmpeg-swscale          1.1.1       Bindings for the ffmpeg swscale library
flac                    0.3.0       Bindings to libflac
gen                     0.5.3       Iterators for OCaml, both restartable and consumable
ladspa                  0.2.0       Bindings for the LADSPA API which provides audio effects
lame                    0.3.5       MP3 encoding library
liquidsoap              2.0.3       pinned to version 2.0.3 at git+file:///usr/local/mediacp/liquidsoap/source#HEAD
mad                     0.5.0       Mad decoding library
menhir                  20211128    An LR(1) parser generator
menhirLib               20211128    Runtime support library for parsers generated by Menhir
menhirSdk               20211128    Compile-time library for auxiliary tools related to Menhir
mm                      0.7.2       The mm library contains high-level to create and manipulate multimedia streams (audio, video, MIDI)
ocaml                   4.08.1      The OCaml compiler (virtual package)
ocaml-base-compiler     4.08.1      Official release 4.08.1
ocaml-config            1           OCaml Switch Configuration
ocaml-migrate-parsetree 1.8.0       Convert OCaml parsetrees between different versions
ocamlbuild              0.14.0      OCamlbuild is a build system with builtin rules to easily build most OCaml projects.
ocamlfind               1.9.1       A library manager for OCaml
ocurl                   0.9.1       Bindings to libcurl
ogg                     0.7.0       Bindings to libogg
opam-depext             1.2.0       Install OS distribution packages
opus                    0.2.0       Bindings to libopus
pcre                    7.4.6       Bindings to the Perl Compatibility Regular Expressions library
ppx_derivers            1.2.1       Shared [@@deriving] plugin registry
ppx_tools_versioned     5.4.0       A variant of ppx_tools based on ocaml-migrate-parsetree
result                  1.5         Compatibility Result module
samplerate              0.1.6       Samplerate audio conversion library
sedlex                  2.2         An OCaml lexer generator for Unicode
ssl                     0.5.10      Bindings for OpenSSL
taglib                  0.3.7       Bindings for the taglib library
theora                  0.4.0       Bindings to libtheora
uchar                   0.0.2       Compatibility library for OCaml's Uchar module
vorbis                  0.8.0       Bindings to libvorbis
toots commented 2 years ago

Just fixed sorry I did some backporting a little to hastly.

TheRealMattLear commented 2 years ago

Thank you! Confirmed compilation success and Unknown Track problem is solved! also confirming that the now playing is updated on new harbor connection as well as when switching back from input.harbor to a playlist

toots commented 2 years ago

Success!

codeofdusk commented 2 years ago

FYI your minimal script contains a secret. Might want to rotate it!