Skip to content

Instantly share code, notes, and snippets.

@devcutler
Last active April 15, 2021 22:20
Show Gist options
  • Save devcutler/21a9efd121336c481b22d7ba739c1492 to your computer and use it in GitHub Desktop.
Save devcutler/21a9efd121336c481b22d7ba739c1492 to your computer and use it in GitHub Desktop.
Stream entire folders of episodes to an RTMP server. Examples are for Brime Live, but you can use any RTMP service. (file format is mkv, but you can change that to anything ffmpeg can handle.)
#!/bin/bash
echo Folder to queue?
read folder
num=$(ls $folder | wc -l)
echo Queued $num episodes. Double-tap \^C to stop.
sleep 2
until [ $epnum -gt $num ]
do
let "epnum+=1"
episode=ep${epnum}.mkv
echo Running ffmpeg stream for episode "$episode"
VBR="8000k" # Stream output bitrate
FPS="24" # Stream output framerate
QUAL="medium" # FFMPEG quality preset (recommended medium, but can use any ffmpeg preset. google them)
STREAM_URL="rtmp://live.brimelive.com/live" # RTMP stream url. (for brime, use this.)
URL="http://localhost:8090/feed1.ffm" # Output feed local url
SOURCE="${folder}/ep${epnum}.mkv" # Video source file (tested with mkv. may work with other formats.)
KEY="KEY GOES HERE" # Stream key (for brime, will be given on brime alpha page)
ffmpeg -i "$SOURCE" -vf subtitles="$SOURCE" -stats -loglevel warning -hide_banner -deinterlace -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 712000 -bufsize 512k -f flv "$STREAM_URL/$KEY"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment