Timestamp to log

Email on start encode
Encode audio 48000 bps
Clearly show error or success in Results page
Optional savedir
This commit is contained in:
root committed 2022-10-09 12:24:15 +07:00
1 parent f0279c4ca2
commit ab642d9c51
6 files changed
+50 -28

No files matched your search

+8 -2
View File
@@ -8,6 +8,7 @@
# has to be a dot!) and the "target" at the very end, after the last '@'.
# Required: ffmpeg coreutils(tail rm)
_=$(readlink -f -- "${BASH_SOURCE:-$0}") repopath=${_%/*}
log=$repopath/process.log
in=$repopath/uploadpage/streams/$1.mp4 key=${1%%.*} target=${1##*@}
@@ -17,12 +18,17 @@ 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
source "$repopath/vars" # I:savedir
# Stream, log it, and remove all files if successful
set -o pipefail # to get ffmpeg's returncode
ffmpeg -re -y -i "$in" -c:v copy -c:a copy -f flv "$rtmp" 2>&1 |tail -n 20 >"$in.log" &&
rm "$in.log" "$in" "${in%.mp4}" ||
if ffmpeg -re -y -i "$in" -c:v copy -c:a copy -f flv "$rtmp" 2>&1 |tail -n 20 >"$in.log"
then
rm "$in.log" "${in%.mp4}"
[[ $savedir && -f $savedir ]] && mv "$in" "$savedir" || rm "$in"
else
echo "Error while streaming $1" >>"$log"
fi
# In any case, comment-out the crontab entry so it's not waiting for next year
crontab -l| sed "/$1/ s/^/#/" |crontab -