How to create your 24/7 YouTube online radio Latest Method

  • Indiasocialbook blocked ?Unblock it by downloading free vpn from -- (HERE)

  • You Must Read our New Rules and Guidelines (HERE)

Ruchika oberoi

Administrator
Staff member
Mar 27, 2022
5,228
132
63

How to create your 24/7 YouTube online radio Latest Method​

  1. Rent a 24/7 server with a stable internet
  2. Use to create an audio stream
  3. Upload mp3/wav files (mind the license)
  4. Use to create a video stream from .mp4 / .gif, merge it with an audio stream with ‘current track’ title and send it to YouTube
Need more details and a step-by-step guide? Let’s go!

1. Find a stable server​

Of course, you can host your 24/7 radio on your Laptop or Raspberry pi, but if you have some strong planes on your radio or just don’t want a headache I’d strongly recommend ordering a 24/7 server with great Internet connections. Digitalocean is one of the greatest and cheapest solutions right now — use my referral to get $100 free to start and test your radio.

You must be registered for see images
My radio server configuration

What about server configurations?​

My current configuration is 4GB RAM / 2CPUs / 80 GB SSD / 4 TB transfer.

My average CPU load is 55%, outbound bandwidth: 1.58 Mbps.

It would probably be enough with a cheaper server but I don’t want to hit the limits — they cause a headache.

2. Install Azuracast​

If you are using as your VPS provider, there is a with Azuracast installed. So you can just install all Azuracast dependencies without any hassle in Terminal (but you will definitely have some soon while installing FFmpeg for merging audio and video streams and sending them to YouTube).

If you want to install Azuracast from scratch — use .

3. Setup Azuracast and Upload tracks​

After successful installation, just visit Azuracast address to complete the setup. Then you just upload song files to the system, create playlists with them — and your radio is already can be listened via Azuracast’s public page (you can find its link in your admin panel).

4. Install FFmpeg​

Now you need this great tool to create a video stream out of your animated .gif or .mp4 file, merge it with your audio stream from Azuracast and pass all of them to YouTube.

To install FFmpeg type this in your terminal:

sudo apt install ffmpeg

Or visit this official site:

5. Run FFmpeg​

Check my production code below. Some descriptions to used variables:

  • YOUTUBE_URL — the URL of YouTube’s streaming service.
  • KEY — the unique key to control your stream. You can find yours straight after the creation of a new youtube online stream (Youtube will give it to you). Keep it safe!
  • VIDEO_SOURCE — path to a file with your animated cover that is located on your server (you can use scp utility to transfer files to your machine).
  • AUDIO_SOURCE — URL to your audio stream. Replace the IP with your host.
#! /bin/bash VBR="1500k" FPS="24" QUAL="superfast" YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" KEY="z5k3-8888-69qu-9999" VIDEO_SOURCE="/home/root/cover.gif" AUDIO_SOURCE=" " ffmpeg \ -re -f lavfi -i "movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)" \ -thread_queue_size 512 -i "$AUDIO_SOURCE" \ -map 0:v:0 -map 1:a:0 \ -map_metadata:g 1:g \ -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \ -acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \ -f flv "$YOUTUBE_URL/$KEY"
You would probably need to wrap up this bash script (with FFmpeg) to . It will relaunch the script after it somehow fails (and it will sometimes).

6. Add CURRENT TRACK captions on a video​

FFmpeg is so powerful it can add a text on the video stream. It can read text from a text file and write its text on the video using your font and coordinates.

You need to create a code that will write a current track name in a text file. There are two ways to do that:

  1. using Azuracast API — you can periodically get the current radio track
  2. using Azuracast Webhooks — you can receive data when song changes
I chose the second variant. You can find a Webhook section in Azurast admin panel. This is my production python code that handles the webhook and writes a song name to the file.

import os, json from flask import Flask, request app = Flask(__name__) FNAME = "song.txt" @app.route('/', methods=['POST','GET']) def index(): with open(FNAME, "w") as f: req_data = request.get_json() if "now_playing" in req_data: if "song" in req_data["now_playing"]: if "text" in req_data["now_playing"]["song"]: text = req_data["now_playing"]["song"]["text"] f.write(text) return '{"success":"true"}' if __name__ == "__main__": app.run(host='0.0.0.0', port=5000)
This is the new FFmpeg launcher that writes text on a video stream:

#! /bin/bash VBR="1500k" FPS="24" QUAL="superfast" YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" KEY="z5k3-8888-69qu-9999" VIDEO_SOURCE="/home/root/cover.gif" AUDIO_SOURCE=" " NP_SOURCE="/home/root/song.txt" FONT="/home/root/VinMonoPro-Light.ttf" ffmpeg \ -re -f lavfi -i "movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)" \ -thread_queue_size 512 -i "$AUDIO_SOURCE" \ -map 0:v:0 -map 1:a:0 \ -map_metadata:g 1:g \ -vf drawtext="fontsize=20: fontfile=$FONT: \ box=0: boxcolor=[email protected]: boxborderw=20: \ textfile=$NP_SOURCE: reload=1: fontcolor=[email protected]: x=50: y=th" \ -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \ -acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \ -f flv "$YOUTUBE_URL/$KEY"
Notice that I also have to upload a font file to the server machine. You can also google for -vf drawtex params to play with song name positioning.

I hope you enjoyed this article! If you create an online radio station using this tutorial — please share its link in the comments section. Please follow me for more hacks and do the clap-clap thing!
 
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock