Skip to content

Instantly share code, notes, and snippets.

@ohld
Created April 9, 2020 20:41
Show Gist options
  • Save ohld/aa161f62d48da21ffc7f735c8dd74720 to your computer and use it in GitHub Desktop.
Save ohld/aa161f62d48da21ffc7f735c8dd74720 to your computer and use it in GitHub Desktop.
How to create 24/7 radio on Youtube (like lo fi radio for study / chill / relax)
#! /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="http://134.122.81.86/radio/8000/radio.mp3"
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=black@0.5: boxborderw=20: \
textfile=$NP_SOURCE: reload=1: fontcolor=white@0.8: 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment