direttoforo/contrib/liquidsoap/http.liq
boyska 7ce86918bc liquidsoap can understand if a stream is "up"
(provided the liq script is complex enough!)
2017-07-24 02:32:54 +02:00

38 lines
1 KiB
Text

#!/usr/bin/env liquidsoap
# A simple script that will both record to file and expose an http server.
# The http server uses (aggressive) silence detection
set('log.file', false)
set('log.stdout', true)
rec_up = interactive.bool("rec_up", false)
icecast_up = interactive.bool("icecast_up", false)
def var_ok(varname) =
fun () -> ignore(server.execute("var.set #{varname} = true"))
end
def var_ko(varname) =
fun () -> ignore(server.execute("var.set #{varname} = false"))
end
audioin = in()
audioin = rewrite_metadata([("artist", "Direttoforo")], audioin)
audioin = server.rms(id="rms", audioin)
f = output.file(
id="rec",
%vorbis(quality=0.2, samplerate=44100, channels=2),
on_start=var_ok("rec_up"),
on_stop=var_ko("rec_up"),
"rec/%Y/%m/rec-%Y-%m-%d_%H-%M-%S.ogg",
audioin
)
http = output.harbor(
id="http",
mount="/stream.ogg",
password="",
fallible=true,
%vorbis(quality=0.1, samplerate=44100, channels=2),
strip_blank(id="strip", max_blank=3., min_noise=0.2, track_sensitive=false, audioin)
)