Created
October 8, 2023 20:15
-
-
Save maietta/63b656055db1ddbd238ace20c8bdb7a7 to your computer and use it in GitHub Desktop.
Shoutcast Relay with Timestamped Slicing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set log level | |
set("log.level", 4) | |
# Capture the remote Shoutcast stream | |
input_stream = input.http("http://your.shoutcast.server/stream") | |
# Function to add breaks every minute | |
def add_breaks(~duration, s) = | |
let duration = duration * 60. in | |
sequence([s, blank(duration)]) | |
end | |
# Add breaks every minute to the input stream | |
sliced_input = add_breaks(1., input_stream) | |
# Function to save a slice every minute | |
def save_slice(m) = | |
timestamp = int_of_float(gettimeofday()) | |
filename = "/path/to/save/directory/"^timestamp^".mp3" | |
output.file(%mp3, fallible=true, append=true, filename, m) | |
end | |
# On each "track" (every minute), save a slice | |
sliced_input = on_track(save_slice, sliced_input) | |
# Relay the stream to an Icecast server | |
output.icecast( | |
%mp3, | |
host = "your.icecast.server", | |
port = 8000, | |
password = "yourpassword", | |
mount = "relay", | |
input_stream | |
) | |
# Play the sliced input (this is necessary to ensure the on_track function is triggered) | |
output.dummy(sliced_input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment