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

Metadata missing with ogg in icecast stream #2917

Open hydrosIII opened 1 year ago

hydrosIII commented 1 year ago

I am running liquidsoap to catch a stream from the internet and send it to and fm transmitter. This stream is in ogg. Recently we changed the stream to mp3 format and we started to see metadata in the logs. This metadata were not visible before. But makes the logs semantic, and maybe is possible to pass it to the transmitter. So we want to know if is possible to read the metadata in the ogg format. When we pass this stream through liquidsoap to an icecast stream in mp3 and send it over to a harbor in another liquidsoap the metadata starts appearing again, so the medata is not lost but is not correctly read.

Liquidsoap version Liquidsoap 2.1.3, installed trough package. Debian bullseye kernel 5.10.0-21-rt-amd64 I can confirm that this happens in previous versions of liquidsoap.

Example of the log in ogg:

feb 17 19:00:40 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header
feb 17 19:05:43 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header
feb 17 19:05:44 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header
feb 17 19:05:44 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header
feb 17 19:05:44 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header
feb 17 19:09:17 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header
feb 17 19:11:47 violetaradio liquidsoap[139840]: [vorbis @ 0x7f5484005600] Ignoring comment header

Example of the log in mp3:

feb 16 13:11:22 violetaradio liquidsoap[102189]: 2023/02/16 13:11:22 [buffer.adaptative_producer_0:3] Buffer emptied, start buffering...
feb 16 13:11:22 violetaradio liquidsoap[102189]: 2023/02/16 13:11:22 [mksafe:3] Switch to safe_blank with transition.
feb 16 13:11:25 violetaradio liquidsoap[102189]: [https @ 0x7f3b240035c0] Metadata update for StreamTitle: Identivarias 3 Dos directora>
feb 16 13:11:26 violetaradio liquidsoap[102189]: [https @ 0x7f3b240035c0] Metadata update for StreamTitle: Identivarias 3 Dos directora>
feb 16 13:11:27 violetaradio liquidsoap[102189]: 2023/02/16 13:11:27 [mksafe:3] Switch to blank.detect_0 with transition.
feb 16 13:18:58 violetaradio liquidsoap[102189]: [https @ 0x7f3b240035c0] Metadata update for StreamTitle: TTTTTTTTTT - Violeta Radio 1>
feb 16 13:18:59 violetaradio liquidsoap[102189]: [https @ 0x7f3b240035c0] Metadata update for StreamTitle: Dia Mundial de la Radio_Viol>
feb 16 13:19:52 violetaradio liquidsoap[102189]: [https @ 0x7f3b240035c0] Metadata update for StreamTitle: Dia Mundial de la Radio_Viol>
feb 16 13:20:18 violetaradio liquidsoap[102189]: [https @ 0x7f3b240035c0] Metadata update for StreamTitle: Id-Violeta-AMARC.mp3

Desired behaviour:

See the metadata of tracks in ogg also.

toots commented 1 year ago

Thanks for reporting. It appears that you are using the ffmpeg decoder and that it is unable to parse in-stream metadata. I would suggest the following:

toots commented 1 year ago

I did not realize that, for input.http streams, we only use the ffmpeg decoder now. Let me investigate this a bit more.

toots commented 1 year ago

Ok, after more testing, I am not sure if I can reproduce. Here's what I've tried:

s = input.http("http://..vorbis..icecast..source")

s = source.on_metadata(s, print)

output.ao(fallible=true, s)

I can definitely see new metadata being printed as the track changes.

hydrosIII commented 1 year ago

Thanks, let me test this new setting.

DroidU commented 1 year ago

Under 2.2.0, even if I specify the settings.decoder.priorities.ogg.set(20) parameter, it stubbornly continues to use the ffmpeg decoder. So unfortunately under this version there is no metadata when transcoding from ogg containers. Any ideas?

toots commented 1 year ago

Under 2.2.0, even if I specify the settings.decoder.priorities.ogg.set(20) parameter, it stubbornly continues to use the ffmpeg decoder. So unfortunately under this version there is no metadata when transcoding from ogg containers. Any ideas?

Unfortunately, input.http relies only on the ffmpeg decoder.

What codec are y'all using with ogg? We've bee investigating an issue specific to the ffmpeg backend with flac. I believe opus is impacted also but haven't had time to submit a patch yet. See: https://github.com/savonet/liquidsoap/issues/3010

DroidU commented 1 year ago

I've tested some combinations, so I'll clarify:

#!/usr/bin/liquidsoap
s=input.http("http://stream.dancewave.online:8080/dw.ogg")
#s=input.http("http://stream.dancewave.online:8080/dance.mp3")
s=source.on_metadata(s,print)
settings.init.allow_root.set(true)
settings.log.file.path.set("streamtranscoder.log")
settings.log.level.set(6)
settings.init.daemon.pidfile.set(true)
settings.init.daemon.pidfile.path.set("streamtranscoder.pid")
settings.log.stdout.set(true)
settings.decoder.priorities.ogg.set(20)
output.icecast(%ogg(%vorbis(quality=0.5,samplerate=44100,channels=2)),host="172.20.0.9",port=2040,mount="/trans.ogg",user="source",password="test",send_icy_metadata=true,mksafe(s))
#output.icecast(%mp3,host="172.20.0.9",port=2040,mount="/trans.mp3",user="source",password="test",send_icy_metadata=true,mksafe(s))

I haven't tested it with Opus and FLAC yet, but the situation will probably be the same for us.

DroidU commented 1 year ago

I tried the latest version cdb94a1. MP3 to OGG encoding now works fine. With VLC, it doesn't get stuck during playback when updating metadata either. If I encode from OGG to another format, there is still no song title. I know this is a ffmpeg dependent thing. But what's strange is that the same encoding works perfectly with the very old Liquidsoap 1.4.4.