snowdusk

blog

My Recipe For Automated Livestreaming (DJ Kate & DJ Kyoko on Tilderadio)

2022-02-18 01:48:00 +0000
#DJing #tilderadio #icecast

ezstream

ezstream is an awesome CLI streaming program. I don't use the latest version though, only because I am not familiar with the configuration in the newest version. I use ezstream version 0.6.1. which you can download here. Download the package, then expand it with tar, then configure, then make install. I'm on macOS X Mojave so installation was just fine. I can't install ezstream using the usual package manager like brew or macports because they will install the latest release - and like I said before, I don't know how to use the latest ezstream release.

After installation, you would then configure an .xml file that ezstream will use to play, decode, encode, and stream music files. I named my DJ Kate ezstream .xml file as ezstream_kate.xml saved in the ~/.ezstream folder in my computer. I save all my different ezstream configurations (.xml files) in that folder. DJ Kyoko has her own ezstream .xml file. Remember, each DJ has their own icecast streaming usernames and passwords that's why each DJ must have separate ezstream .xml files.

I stream solely in OGG format on Tilderadio so my ezstream .xml file does not require decode and encode entries, and fortunately, Tilderadio accepts both OGG and MP3 streams. I prefer OGG because I could split up one single recording of a mix in order to embed the metadata for each track, and ezstream would still play the tracks without any gaps. I usually stream Kate and Kyoko streams live first and record it, then split up the file so I could embed the metadata into each track (split). This is what my ezstream_kate.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<ezstream>
<url>http://azuracast.tilderadio.org:8005/</url>
<sourceuser>kate</sourceuser>
<sourcepassword>PASSWORD</sourcepassword>
<format>OGG</format>
<filename>/Volumes/Mac Pro HDD/Music/radio/kate_20201020/playlist.txt</filename>
<stream_once>1</stream_once>
<svrinfoname>Tilderadio</svrinfoname>
<svrinfourl>https://tilderadio.org</svrinfourl>
<svrinfogenre>Awesome songs from the 50s 60s 70s</svrinfogenre>
<svrinfodescription>DJ KATE'S TALES FROM THE CRATES</svrinfodescription>
<svrinfobitrate>192</svrinfobitrate>
<svrinfosamplerate>44100</svrinfosamplerate>
<!-- No advertising on a public YP directory -->
<svrinfopublic>1</svrinfopublic>
<metadata>
<!-- Program to query for metadata instead of from media files -->
<!-- <program>meta.sh</program> -->

<!-- Metadata format -->
<format_str>@a@ - @t@</format_str>

<!-- Interval for additional metadata refreshes (-1 for none) -->
<refresh_interval>-1</refresh_interval>

<!-- Setting to clean up extraneous whitespace -->
<normalize_strings>Yes</normalize_strings>

<!-- Setting to suppress all metadata udpates -->
<no_updates>No</no_updates>
</metadata>
</ezstream>

My Media Files

This is how I organize my media files. These are folders. Each folder is a live mix that I have done in the past. As stated earlier, I always stream a mix live while recording it. I then split up the recording separating each track so I can embed the metadata.

Each folder contains the already split-up files. Each one with embedded metadata. ezstream will show the metadata of each track as it streams to Tilderadio's icecast server.

I streamed the above playlist (kate_20220213) live on Tilderadio on February 13th, 2022. You will need to tell ezstream the order of how you want to these tracks played. The playlist.txt text file does this for you. This is what playlist.txt looks like.

Fortunately I can split up a recording session on-the-fly thanks to the Track Mark feature of my Pioneer DJM-350 Mixer. This has been a very convenient feature of this mixer. My mixer, by the way, records my livestream session into a USB stick in lossless WAV format as shown on the photo below.

After each livestream session, I would take out the USB stick from my mixer, plug it into my computer, and drag the split-up media files into Audacity - a really awesome free and open source software for editing audio tracks. I try not to alter the recording because I want to maintain the LIVE feel of the recording. I only use Audacity so that I could embed the Metadata for each track, export each track to OGG format and save it to the playlist folder. After I finish exporting and saving all the OGG files into the playlist folder, I then align the tracks end-to-end on Audacity, mix and render, to create a new single lossless WAV format file for uploading to my Soundcloud page so anyone can play the live mix anytime from my Soundcloud page, or from DJ Kate and DJ Kyoko's Mastodon timelines.

Next, we need to tell ezstream to play and stream these playlist in random order.

Pick a playlist at random then stream it with ezstream... without repeating the playlist!

For this I use a bash script. It looks like this:

#!/bin/bash
folder=`find \/Volumes/Mac\ Pro\ HDD/Music\/radio/kate* -maxdepth 100 -type d | /opt/local/bin/gshuf | head -1`
if grep "$folder" /Volumes/Mac\ Pro\ HDD/Music/radio/kate_played.txt
then
/Users/gary/./ezstream_kate_cron.sh
else
sed -i .bak -e "s|.*<\/filename>|${folder}\/playlist.txt<\/filename>|g" /Users/gary/.ezstream/ezstream_kate.xml
/usr/local/bin/ezstream -c /Users/gary/.ezstream/ezstream_kate.xml
echo "$folder" >> /Volumes/Mac\ Pro\ HDD/Music/radio/kate_played.txt
fi

I'm not going to explain the above script in details. Most of my listeners and potential anonradio/tilderadio DJs are hackers. They will figure it out easily :-) I do want to point out that what this script does:

  1. Create a variable called "folder". This is just the full path of the playlist.txt that ezstream will read when it streams. Remember, the playlist.txt file shows a list of OGG files in order of playing (with full path).
  2. Shuffle the playlist folders then pick one folder and assign it to variable "folder"
  3. Check if that playlist has been played before by going through the list of previously played playlists in the kate_played.txt file (next steps will explain how this list is created)
  4. If variable folder is not listed in kate_played.txt file, then plug in the value of $folder to the <filename> value in the ezstream config file, then run ezstream to livestream the playlist
  5. After successful streaming, add the value of the $folder in the kate_played.txt so that ezstream will not play it again (once I run out of playlists to play then I just simply delete the list and start all over again)
  6. However, if $folder is already in the kate_played.txt file (meaning the playlist picked has been played before), then simply rerun the script

Schedule the stream

For this, I use cron. I run crontab -e on the shell. This is how my DJ Kate and DJ Kyoko cronjobs look like:

The cronjobs run a bash script called ezstream_kate_cron.sh and ezstream_kyoko_cron.sh. That script looks like this:

These are just one-liner scripts that opens a terminal window, then run another script (the main ezstream script), and then show ezstream running verbosely, so I will know if the robo DJs ran successfully and see what tracks ezstream played. I really don't want to put the whole script in my cronjobs -- it will look very messy if I did. I really like a nice clean list of cronjobs. The terminal window opened by this script looks like this. This is also how ezstream runs verbosely:

Final Thoughts

And that's about it! Simple, right? I am not a programmer and so you may find my scripts and workflow, well, messy. LOL. Sorry if you find them offensive! Ha ha.

Next time, I will show you how to create an Internet radio station using CLI-based programs only, like icecast, and well, with my dear friend ezstream. No need to run resource-hogging GUI APPS!! ;-)






------------------------------

A note on copyright:

All of the tracks included in my live mixes are not my work, unless otherwise stated. I do not receive any monetary compensation for doing my live shows. My activities on aNONradio.net and Tilderadio are/were/have always been strictly a personal hobby. aNONradio.net and Tilderadio are both for-hobby, not-for-profit, non-commercial and fully volunteer-member-run and funded Internet radio services. If your track/piece of work gets included in my mixes then it means that I love and admire you and your work and I am in effect promoting you and your work to my listeners for free.

However, if you are an artist and are still not satisfied with my explanation in the above paragraph, please contact me.

CREDITS

made with jekyll and vim


powered by the SDF Public Access UNIX System
"Get your own free UNIX shell and free homepage now!"

Titillium Web fonts by Accademia di Belle Arti di Urbino

background image is a screenshot taken from the music video "Mi Teletipo" by Oviformia SCI

codes for website HTML javascript clock obtained from ricocheting.com

jekyll tagging codes and tag_generator.py credits: Long Qian

super-search script by Kushagra Gour (chinchang)