You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m running Liquidsoap (v2.3.3) on Docker, pulling metadata every 5 seconds from a simple HTTP endpoint, but every so often the title just “sticks” at the old value and never updates again. That normaly happens within 5-10 days of running the container.
#!/usr/bin/liquidsoap
# General settings
settings.log.level.set(1)
settings.log.stdout.set(false)
settings.log.file.set(false)
# SRT logs
settings.srt.log.set(false)
# Prevent multiline logs
settings.console.colorize.set("never")
# Prometheus settings
settings.prometheus.server.set(true)
settings.prometheus.server.port.set(9090)
# Prometheus metrics definitions
is_playing_metric = prometheus.gauge(labels=["source"], help="Indicates whether the main source is currently playing.", "liquidsoap_is_playing")
is_fallback_active_metric = prometheus.gauge(labels=["fallback"], help="Indicates whether the fallback source is currently active.", "liquidsoap_is_fallback_active")
srt_status_metric = prometheus.gauge(labels=["source"], help="Indicates whether the SRT source is connected.", "liquidsoap_srt_status")
# Create metric setters
set_is_playing = is_playing_metric(label_values=["main_source"])
set_is_fallback_active = is_fallback_active_metric(label_values=["fallback_source"])
set_srt_status = srt_status_metric(label_values=["srt_source"])
# Function to fetch metadata from a URL
def fetch_meta(url) =
result = http.get(url)
if result != "" then
result
else
"unknown title"
end
end
# Define the URL to fetch metadata from
url = "https://api.radiomv.com/english.txt"
def on_socket(~mode, s) =
if mode == "listen" then
# wrap the raw handle in an SRT socket object
s = srt.socket(s)
print("Setting latency to 350 ms and rcvbuf to 524288 on listening socket")
s.set_latency(350)
s.set_rcvbuf(524288)
end
if mode == "incoming" then
s = srt.socket(s)
print("Incoming socket latency: #{s.latency()} ms, rcvbuf: #{s.rcvbuf()} bytes")
end
end
# Create a source with insert_metadata method and higher static latency
source = insert_metadata(input.srt(id="input_srt", mode="listener", port=${SRT_PORT}, on_socket=on_socket))
safe_blank = blank(id="safe_blank")
# Create a safe_source with insert_metadata method
safe_source = insert_metadata(fallback(track_sensitive=false, [source, safe_blank]))
# Define a function to periodically fetch and update metadata
def update_meta() =
fetched_meta = fetch_meta(url)
# log("Fetched metadata: #{fetched_meta}")
safe_source.insert_metadata([("title", fetched_meta)])
5.0
end
# Set up periodic updates every 5 seconds
thread.run.recurrent(update_meta)
# Check if the source or fallback is playing
def check_if_playing() =
if source.is_ready() then
set_is_playing(1.0)
set_is_fallback_active(0.0)
else
set_is_playing(0.0)
set_is_fallback_active(1.0)
end
1.0
end
# Check if the SRT source is connected
def check_srt_status() =
if source.is_ready() then
set_srt_status(1.0)
else
set_srt_status(0.0)
end
1.0
end
# Set up periodic checks every second
thread.run.recurrent(check_if_playing)
thread.run.recurrent(check_srt_status)
# Output sources with varying quality
lofi = %ffmpeg(format="adts", interleaved=false, %audio(channels=2, samplerate=44100, codec="libfdk_aac", b="24k", profile="aac_he_v2"))
midfi = %ffmpeg(format="adts", interleaved=false, %audio(channels=2, samplerate=44100, codec="libfdk_aac", b="96k", profile="aac_he_v2"))
hifi = %ffmpeg(format="adts", interleaved=false, %audio(channels=2, samplerate=44100, codec="libfdk_aac", b="128k", profile="aac_he"))
mp3 = %ffmpeg(format="mp3", %audio(channels=2, samplerate=44100, codec="libmp3lame", b="128k"))
# Define the HLS segment naming
def segment_name(metadata) =
# Use metadata attributes to generate the segment name
"#{metadata.stream_name}_#{metadata.duration}_#{metadata.position}_#{metadata.extname}.aac"
end
# Log when a new segment is created
def on_file_change(~state, fname) =
if state == "closed" and file.extension(fname) != '.m3u8' then
log.important(label="hls", "Segment #{fname} created")
end
end
output.file.hls(id="output_hls",
playlist="live.m3u8",
segment_duration=6.0,
segments=5,
segments_overhead=5,
segment_name=segment_name,
on_file_change=on_file_change,
persist_at="state.config",
temp_dir="/hls",
"/hls",
[("hifi", hifi),
("midfi", midfi),
("lofi", lofi)],
safe_source)
# Icecast output
output.icecast(
mp3,
encoding="ISO-8859-1",
mount="/${STATION_NAME}.mp3",
host="icecast-${STATION_NAME}",
port=${ICECAST_HTTP},
user="${ICECAST_MOUNT_USER}",
password="${ICECAST_MOUNT_PASSWORD}",
safe_source)
What I’ve tried so far
Logging the fetched value inside update_meta (no errors, but still “sticks” sometimes)
Increasing the interval to 10 s (same symptoms)
Verifying the HTTP endpoint always returns the latest text
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone,
I’m running Liquidsoap (v2.3.3) on Docker, pulling metadata every 5 seconds from a simple HTTP endpoint, but every so often the title just “sticks” at the old value and never updates again. That normaly happens within 5-10 days of running the container.
What I’ve tried so far
update_meta
(no errors, but still “sticks” sometimes)Beta Was this translation helpful? Give feedback.
All reactions