Created
November 22, 2016 14:38
-
-
Save hex128/68a789a5bdc21e55d671d8d6ecde4ae1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ontrap () { | |
for j in $(jobs -p) | |
do | |
kill -s SIGTERM $j > /dev/null 2>&1 || (sleep 1 && kill -9 $j > /dev/null 2>&1 &) | |
done | |
} | |
trap ontrap INT TERM EXIT | |
server () { | |
while : | |
do | |
python -m SimpleHTTPServer 8000 | |
done | |
} | |
stream () { | |
while : | |
do | |
${phantomjs} runner.js | ${ffmpeg} \ | |
-y -c:v png -f image2pipe -r 1 \ | |
-i - -f lavfi -i anullsrc \ | |
-c:v libx264 -pix_fmt yuv420p -preset ultrafast -vf fps=25 \ | |
-c:a aac -ar 44100 -ac 2 \ | |
-f flv ${rtmp} | |
done | |
} | |
phantomjs='/usr/local/bin/phantomjs' | |
ffmpeg='/usr/local/bin/ffmpeg' | |
rtmp=${1} | |
server & | |
stream & | |
wait $(jobs -p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment