Skip to content

Instantly share code, notes, and snippets.

@ashfame
Created June 21, 2020 08:41
Show Gist options
  • Save ashfame/22a1a7badfb7735febff2cbcec65661c to your computer and use it in GitHub Desktop.
Save ashfame/22a1a7badfb7735febff2cbcec65661c to your computer and use it in GitHub Desktop.
Shared nginx file for streaming to multiple platforms - untested, shared by a friend
#user nobody;
worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
# sample handlers
location /on_play {
if ($arg_pageUrl ~* localhost) {
return 201;
}
return 202;
}
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# you can move stat.xsl to a different location
root /usr/build/nginx-rtmp-module;
}
# rtmp control
location /control {
rtmp_control all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 1935;
ping 30s;
notify_method get;
# RTMP URL is rtmp://server_ip:1935/restream
application restream {
live on;
# push [[TWITCH_LIVE_URL]];
# push [[YOUTUBE_LIVE_URL]];
# push [[FACEBOOK_LIVE_URL]];
# The following entry uses ffmpeg to downscale to 720p for Facebook
# exec ffmpeg -re -i rtmp://localhost:1935/restream/$name -vf scale=-1:720 -c:v libx264 -g 2 -preset ultrafast -c:a aac -threads 8 -f flv [[FACEBOOK_LIVE_URL]];
}
application myapp {
live on;
on_play http://localhost:8080/on_play;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment