A tool for recording internet radio streams (Shoutcast/Icecast/HTTP streams) to disk with automatic track-splitting, ID3/Vorbis metadata tagging, and cover-art embedding — driven by Liquidsoap and controlled through a desktop GUI (with an optional web interface).
The project has three parts:
| File | Role |
|---|---|
record.liq |
The Liquidsoap script that does the actual stream capture, file writing, metadata handling, and post-processing. |
liquidsoap-record-ui.py |
A Tkinter desktop application that builds the command line for record.liq, launches/monitors it as a subprocess, and optionally exposes the same controls over a small built-in web server. |
build_cover_metadata.py |
A helper invoked by record.liq to embed cover art in Ogg Vorbis / Opus files (a format that ffmpeg's normal attached_pic shortcut doesn't support). |
- You configure a stream URL, output directory, format/codec, and various options either in the GUI or on the liquidsoap command line.
- The GUI (
liquidsoap-record-ui.py) assembles these into aliquidsoap record.liq -- -url ... -dir ... ...command and runs it as a subprocess, streaming its log output back into the GUI/web log panel. record.liqconnects to the stream (viainput.ffmpeg), writes audio to disk, and either:- copies the source stream as-is ("stream copy" mode), or
- transcodes it to a chosen format/codec/bitrate/samplerate.
- Track metadata (ICY
artist/title, or a combinedtitlestring) is parsed, cleaned, and used to split the recording into per-track files (unless "single" mode is enabled, in which case it records one continuous file). - When a new track starts,
record.liqcan optionally look up cover art (from a metadata URL, TuneIn, or Deezer) and embed it into the finished file withffmpegonce the track is complete — usingbuild_cover_metadata.pyfor the Ogg/Opus cases. - Liquidsoap also exposes a tiny HTTP control server (
harbor.http) on127.0.0.1:1234with a/stop_allendpoint the GUI uses to shut it down gracefully.
Liquidsoap script (targets Liquidsoap 2.4.5 / 2.5.0) invoked as:
liquidsoap record.liq -- \
-url "<stream url>" \
-dir "<output directory>" \
-station "<station name>" \
-transcode <0|1> \
-samplerate "<samplerate>" \
-format "<mp3|m4a|flac|ogg|opus>" \
-codec "<libmp3lame|aac|flac|libopus|vorbis>" \
-bitrate "<bitrate>" \
-listen <0|1> \
-device "<portaudio|alsa>" \
-log <1-4> \
-keep <0|1> \
-id "<tunein id>" \
-relay <0|1> \
-host "<icecast relay host>" \
-port <icecast relay port> \
-password "<icecast relay password>" \
-m3u <0|1> \
-covers <0|1> \
-single <0|1> \
-timeout <seconds, 0 = unlimited>
Key behavior:
- Folder naming — uses the station name if given, otherwise probes the
stream's ICY
icy-namewithffprobe, otherwise falls back to a sanitized version of the URL. - Stream copy vs. transcode — if
-transcode 0,ffprobeis used to detect the source codec and the stream is copied through without re-encoding; if-transcode 1, audio is re-encoded to the requested format/codec/bitrate/samplerate. - Metadata cleanup — normalizes uppercase
ARTIST/TITLEtags, and splits combined"Artist - Title"(orArtist ? Title) strings into separate artist/title fields, stripping trailing[...]/|...junk. - Track splitting —
reopen_on_metadatareopens the output file whenever the artist/title changes, naming each file after the sanitized artist/title (or just title, or a timestamp if no metadata is available). Disabled entirely in-single 1mode. - Cover art — when
-covers 1, on each new track it tries, in order: a cover URL embedded in the stream's metadata, a TuneIn "now playing" image (if-idis set), or a Deezer search by artist/title. The image is downloaded, then muxed into the finished file withffmpegonce the file closes (FLAC/MP3/M4A use-disposition:v attached_pic; Ogg/Opus usebuild_cover_metadata.pyto build a properMETADATA_BLOCK_PICTUREtag). If muxing fails for any reason, the original (uncovered) recording is kept rather than lost. - M3U — when
-m3u 1, writes a#listen.m3uplaylist file pointing at the source URL into the output folder. - Icecast relay — when
-relay 1, additionally re-streams the audio out to an Icecast server (AAC/ADTS, 320k) at the given host/port/password, and can push live artist/title/cover-url ICY metadata updates to it. - Listening — when
-listen 1, plays the audio live throughoutput.portaudiooroutput.alsa(whichever is compiled in). - Timeout / watchdog — a background thread checks elapsed recording time
every second and calls
shutdown()once-timeout(seconds) is reached. - Control endpoint —
harbor.httplistens on127.0.0.1:1234and exposesGET /stop_all, which callsshutdown().
Stream Copy
liquidsoap record.liq -- -url "http://ice1.somafm.com/groovesalad-256-mp3" -dir "c:\music"
Transcoding
liquidsoap record.liq -- -url "https://stream.radioparadise.com/rock-flacm" -dir "c:\music" -transcode 1 -samplerate 48000 -format opus -codec libopus -bitrate 128k
Stream Copy with tunein_id (e.g) https://tunein.com/radio/Roxx-Radio-s240638/
liquidsoap record.liq -- -url "http://stream.radiojar.com/aay95tkmb" -dir "c:\music" -covers 1 -id s240638
Transcoding suggestions table
| format | arguments |
|---|---|
| OPUS | -samplerate 48000 -format opus -codec libopus -bitrate 128k |
| MP3 | -samplerate 44100 -format mp3 -codec libmp3lame -bitrate 320k |
| AAC | -samplerate 44100 -format mp4 -codec aac -bitrate 320k |
| FLAC | -samplerate 44100 -format flac -codec flac |
A single-file Tkinter application (Linux/Windows/macOS) that wraps
record.liq:
- Recorder tab — start/stop controls, live status, elapsed time, current
file being recorded, a log panel, and a built-in Icecast relay player
(via
mpvorffplay, with a volume slider) for monitoring the relay output. - Options tab — every
record.liqflag exposed as a form field (stream URL, directory, station, transcode/codec/format/bitrate/samplerate, listen device, log level, keep-incomplete, timeout, TuneIn ID, M3U, covers, single-track mode, Icecast relay host/port/password) plus web interface settings. - Files tab — a browsable tree of the recording output directory, with "open file" / "open containing folder" actions.
- Builds the actual
liquidsoap record.liq -- ...command line from the form (build_command), can show/copy it, and launches it as a subprocess, parsing its stdout/stderr into the log panel and status fields in real time. - Stops recording gracefully by calling the
/stop_allHTTP endpoint first (falling back to killing the process if it doesn't exit in time). - Persists all settings between runs to
~/.liquidsoap_record_parameters.json; explicit command-line arguments to the GUI itself always override saved values. - Detects and displays the installed Liquidsoap version and the
record.liqscript version (parsed from its header comment). - Optional web interface — an embedded
ThreadingHTTPServer(off by default, toggle in Options) serves a single-page control UI plus a small JSON API (GET /api/status,/api/parameters,/api/log;POST /api/start,/api/stop,/api/parameters) so the recorder can be started/stopped/monitored remotely, e.g. from a phone browser. - Supports light/dark themes (persisted) and can be launched with
--start-recordingto begin recording immediately on startup.
Run it with python3 liquidsoap-record-ui.py [options] — see
parse_arguments() in the script (or --help) for the full list of
command-line overrides, which mirror the record.liq flags above plus
--web, --web-host, and --web-port.
build_cover_metadata.py <cover_image> <output_metadata_file>
A standalone helper called by record.liq's post-processing step for Ogg
Vorbis and Opus output. ffmpeg's -disposition:v attached_pic shortcut
(used for FLAC/MP3/M4A) doesn't produce a valid cover tag for Ogg-family
containers, so this script builds the required METADATA_BLOCK_PICTURE
value by hand, per the
Xiph FLAC picture block spec:
- Guesses the image's MIME type from its file extension and probes its
pixel dimensions with
ffprobe. - Packs the FLAC
PICTUREmetadata block (type = front cover, MIME type, empty description, width/height/depth/colors, and the raw image bytes) and base64-encodes it. - Writes it out as an
;FFMETADATA1file containing a singleMETADATA_BLOCK_PICTURE=<base64>line.
record.liq then feeds that file back into ffmpeg with
-i metadata.txt -map_metadata 1, avoiding the need to pass a large base64
blob as a command-line argument. On any failure it exits non-zero and
writes nothing to the output file, so the caller can detect the failure and
keep the original (uncovered) recording instead of losing it.
- Liquidsoap 2.4.5 / 2.5.0 (built with
output.portaudio/output.alsasupport if you want live listening) ffmpeg/ffprobe- Python 3 (for the GUI and
build_cover_metadata.py); Tkinter for the GUI mpvorffplay(optional, for the built-in Icecast relay player)


