Skip to content
DatanoiseTV edited this page Jun 18, 2026 · 1 revision

AutoDJ

The AutoDJ is an internal audio source that behaves like an external encoder: it decodes files from disk, transcodes them, and writes paced chunks into a mount's buffer. You can run multiple independent AutoDJ instances, each on its own mount with its own library, format, and control port.

Manage them in Admin → AutoDJ (full CRUD with inline edit) or via the JSON API. Configuration lives under autodjs in Configuration.

Minimal instance

"autodjs": [
    {
        "name": "24/7 Chill",
        "mount": "/chill",
        "music_dir": "/music/chill",
        "format": "mp3",
        "bitrate": 128,
        "enabled": true,
        "loop": true,
        "inject_metadata": true,
        "visible": true
    }
]
Field Notes
name, mount Display name and the mount it publishes to.
music_dir Directory scanned for audio files.
format Output codec: mp3 or opus.
bitrate Output bitrate (kbps).
loop Restart the playlist when it ends.
inject_metadata Emit ICY "now playing" from file tags.
visible Show in public listings.
playlist, last_playlist Ordered track list / last saved playlist name.

Supported input formats

The AutoDJ (and the transcoder) decode in pure Go:

MP3 · Ogg Opus · Ogg Vorbis · FLAC · FLAC-in-Ogg · WAV (8/16/24/32-bit PCM and IEEE float, mono or stereo).

When the output is Opus, audio is automatically resampled to 48 kHz, so MP3/Vorbis/FLAC/WAV sources no longer play ~8.8 % too fast. MP3 output honours the configured bitrate exactly. ID3 tags are read with a pure-Go parser.

Playback is paced to real time: the streamer sleeps to match each frame's duration so it fills the buffer at playback speed rather than flooding it.

Playlists, queue, and shuffle

From Admin → AutoDJ → Studio (a 3-column live console: library browser, playlist editor, transport, visualiser, mount switcher) or the API (HTTP API):

  • Browse and add files, reorder the playlist, save/load named playlists.
  • A separate queue is inserted ahead of the regular playlist (add / remove / reorder).
  • Toggle shuffle, loop, and metadata injection live.
  • Transport: play/pause, restart, skip to next, rescan the directory.

MPD remote control

Each AutoDJ instance can expose a minimal MPD protocol port so MPD clients (mpc, ncmpcpp, MALP, …) drive playback:

{ "mpd_enabled": true, "mpd_port": "6600", "mpd_password": "secret" }

The MPD password is compared in constant time; the command_list_* accumulator is bounded so a client can't exhaust memory by opening a list and never closing it.

Track hooks

Two ways to run something on track change. Both run as the service user.

song_command — pick the next track

An external program that selects the next file (a scheduler, rotation engine, or request system). Runs with song_command_timeout seconds to respond.

on_play_command — notify on track start

A shell command run asynchronously at each track start, with metadata in the environment:

#!/bin/bash
curl -s "https://air.radiotime.com/Playing.ashx?partnerId=$P&partnerKey=$K&id=$ID&title=${TINYICE_TITLE}&artist=${TINYICE_ARTIST}"
Variable
TINYICE_ARTIST · TINYICE_TITLE · TINYICE_ALBUM Track tags
TINYICE_FILE Source file path
TINYICE_MOUNT Mount the track is playing on

on_play_command_timeout bounds the run; child shells get SIGKILL if the AutoDJ is stopped (the streamer cancels its lifetime context).

Both commands execute arbitrary shell strings, so creating or editing an AutoDJ requires the superadmin role — a lower-privileged user can't smuggle in a song_command that runs as the service account. See Security. If you prefer HTTP over a local script, the now_playing webhook fires on the same event.


Next: Transcoding · Webhooks · HTTP API

Clone this wiki locally