http.liq 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env liquidsoap
  2. # A simple script that will both record to file and expose an http server.
  3. # The http server uses (aggressive) silence detection
  4. set('log.file', false)
  5. set('log.stdout', true)
  6. rec_up = interactive.bool("rec_up", false)
  7. icecast_up = interactive.bool("icecast_up", false)
  8. def var_ok(varname) =
  9. fun () -> ignore(server.execute("var.set #{varname} = true"))
  10. end
  11. def var_ko(varname) =
  12. fun () -> ignore(server.execute("var.set #{varname} = false"))
  13. end
  14. audioin = in()
  15. audioin = rewrite_metadata([("artist", "Direttoforo")], audioin)
  16. audioin = server.rms(id="rms", audioin)
  17. f = output.file(
  18. id="rec",
  19. %vorbis(quality=0.2, samplerate=44100, channels=2),
  20. on_start=var_ok("rec_up"),
  21. on_stop=var_ko("rec_up"),
  22. "rec/%Y/%m/rec-%Y-%m-%d_%H-%M-%S.ogg",
  23. audioin
  24. )
  25. http = output.harbor(
  26. id="http",
  27. mount="/stream.ogg",
  28. password="",
  29. fallible=true,
  30. %vorbis(quality=0.1, samplerate=44100, channels=2),
  31. strip_blank(id="strip", max_blank=3., min_noise=0.2, track_sensitive=false, audioin)
  32. )