Skip to content

Instantly share code, notes, and snippets.

@donis
Last active April 19, 2016 20:16
Show Gist options
  • Save donis/915557c3a203023dfb6e8401fcbc0a5e to your computer and use it in GitHub Desktop.
Save donis/915557c3a203023dfb6e8401fcbc0a5e to your computer and use it in GitHub Desktop.
Nginx configuration for streaming
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# ===============
# This is custom location for rtmp stats page
# ===============
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# you can move stat.xsl to a different location
root /usr/local/nginx/html;
}
}
}
# RTMP configuration
rtmp {
server {
listen 1935;
chunk_size 4096;
# This is the recording and encoding part
application live_gog {
live on;
exec /usr/bin/ffmpeg -i "rtmp://**HOSTNAME**/live_gog/donis_streams" -vb 3500k -minrate 3500k -maxrate 3500k -bufsize 3500k -s 1280x720 -c:v libx264 -preset veryfast -r 30 -g 60 -keyint_min 30 -x264opts "keyint=60:min-keyint=60:no-scenecut" -sws_flags lanczos -tune film -pix_fmt yuv420p -c:a copy -f flv -threads 4 -strict normal "rtmp://**HOSTNAME**/out_gog/donis_streams2";
record_path /home/donis/streams;
recorder allin_gog {
record all;
record_suffix -gog-%F-%H-%M-%S.mkv;
}
}
# This is streaming part, FFMPEG redirects it to rtmp://**HOSTNAME**/out_gog/donis_streams2 which is actually this part.
application out_gog {
live on;
record off;
# gogcom
push rtmp://live-ams.twitch.tv/app/***STREAM_KEY***;
}
application live_donis {
live on;
exec /usr/bin/ffmpeg -i "rtmp://**HOSTNAME**/live_donis/donis_streams" -vb 2000k -minrate 2000k -maxrate 2000k -bufsize 2000k -s 1280x720 -c:v libx264 -preset veryfast -r 30 -g 60 -keyint_min 30 -x264opts "keyint=60:min-keyint=60:no-scenecut" -sws_flags lanczos -pix_fmt yuv420p -c:a copy -f flv -threads 4 -strict normal "rtmp://**HOSTNAME**/out_donis/donis_streams2";
record_path /home/donis/streams;
recorder allin_donis {
record all;
record_suffix -donis-%F-%H-%M-%S.mkv;
}
}
application out_donis {
live on;
record off;
push rtmp://live-ams.twitch.tv/app/***STREAM_KEY***;
}
application live_test {
live on;
exec /usr/bin/ffmpeg -i "rtmp://**HOSTNAME**/live_test/donis_streams" -vb 2000k -minrate 2000k -maxrate 2000k -bufsize 2000k -s 1280x720 -c:v libx264 -preset veryfast -r 30 -g 60 -keyint_min 30 -x264opts "keyint=60:min-keyint=60:no-scenecut" -sws_flags lanczos -pix_fmt yuv420p -c:a copy -f flv -threads 4 -strict normal "rtmp://**HOSTNAME**/out_test/donis_streams2";
record_path /home/donis/streams;
recorder allin_test {
record all;
record_suffix -test-%F-%H-%M-%S.mkv;
}
}
application out_test {
live on;
record off;
# donis_test
push rtmp://live-fra.twitch.tv/app/***STREAM_KEY***;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment