Recently one of my customer need to restream their Radio Live Stream on YouTube. So, I helped them to do Live Radio Stream on YouTube.
If you also need to stream Radio Stream to YouTube you will need a VPS server with FFmpeg installed. FFmpeg is a free open source, cross-platform solution to record, convert and stream audio and video.
Ubuntu Install FFmpeg
# apt install ffmpegYou need to get YouTube Live URL & KEY from YouTube Live Dashboard
radio.sh
#! /bin/bash VBR="1500k" FPS="24" QUAL="superfast" YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" KEY="xxxx-xxxx-xxxx-xxxx" VIDEO_SOURCE="/home/radio.gif" AUDIO_SOURCE="http://[radio-server-ip-address]:[port]/stream" 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"
Replace [radio-server-ip-address] with your Radio Server IP Address and [port] with Radio Stream Port
Replace KEY with YouTube Live stream Key
VIDEO_SOURCE will be used to show animated gif as placeholder for YouTube Video while broadcasting Music from Radio Stream
Run Radio Live Stream for YouTube
# chmod a+x radio.sh # ./radio.sh
Make this shell script run in background
Make sure your Radio Stream is Online, you can check your radio stream here Is Radio Stream Online?