#!/usr/bin/env bash # stream - Stream video when called from crontab # Usage: stream # The tag refers to video files in $repopath/uploadpage/streams without the # '.mp4', that should have been re-encoded by `encode`. The tag has no path # information, has the "streamkey" at the start before the dot (it has to have # a dot!) and the "target" at the very end, after the '@'. _=$(realpath -- "${BASH_SOURCE:-$0}") repopath=${_%/*} log=$repopath/process.log in=$repopath/uploadpage/streams/$1.mp4 key=${1%%.*} target=${1##*@} case $target in Facebook) rtmp=rtmps://live-api-s.facebook.com:443/rtmp/$key ;; YouTube) rtmp=rtmp://a.rtmp.youtube.com/live2/$key ;; RestreamSG) rtmp=rtmp://singapore.restream.io/live/$key ;; *) rtmp=rtmp://live.restream.io/live/$key esac /usr/bin/ffmpeg -re -y -i $in -c:v copy -c:a copy -f flv "$rtmp" || echo "Error while streaming $1" >>"$log"