Skip to content

Instantly share code, notes, and snippets.

@EvilFreelancer
Last active August 15, 2018 20:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvilFreelancer/3158e3bf5ee784ef821bc496af9849ad to your computer and use it in GitHub Desktop.
Save EvilFreelancer/3158e3bf5ee784ef821bc496af9849ad to your computer and use it in GitHub Desktop.
Nginx RTMP edition with init script and config file
#!/bin/bash
function help {
echo "$0 [start|stop|reload|restart]"
exit
}
path="/linux/Linux/nginx-rtmp/binary"
bin="sbin/nginx"
case "$1" in
"start")
echo -n "INF: $bin starting... "
$path/$bin
echo "done"
;;
"stop")
echo -n "INF: $bin stoping... "
$path/$bin -s stop
echo "done"
;;
"reload")
echo -n "INF: $bin reloading... "
$path/$bin -s reload
echo "done"
;;
"restart")
$0 stop
$0 start
;;
*)
help
;;
esac
# server UID
user www-data;
# multiple workers works !
worker_processes 1;
events {
worker_connections 8192;
}
rtmp {
server {
listen 1935;
chunk_size 8192;
application all {
live on;
record off;
# Send to normal platforms without encoding
push rtmp://localhost/twitch;
# Resize the livecoding stream
exec ffmpeg -i rtmp://localhost/all -vcodec libx264 -preset veryfast -b:v 2000k -maxrate 2000k -bufsize 2000k -s 1280x720 -sws_flags lanczos -r 30 -acodec copy -f flv rtmp://localhost/livecoding;
}
application games {
live on;
record off;
# Send to normal platforms without encoding
push rtmp://localhost/twitch;
push rtmp://localhost/youtube;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment