Skip to content

Instantly share code, notes, and snippets.

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 sumonst21/2160b5cb147f8364933fa6d86b4b81ff to your computer and use it in GitHub Desktop.
Save sumonst21/2160b5cb147f8364933fa6d86b4b81ff to your computer and use it in GitHub Desktop.
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 80 default;
listen [::]:80 default;
server_name _;
charset utf-8;
location /hls_240 {
root /tmp;
autoindex on;
}
location /hls_360 {
root /tmp;
autoindex on;
}
location /hls_480 {
root /tmp;
autoindex on;
}
location /hls_720 {
root /tmp;
autoindex on;
}
location /hls_1080 {
root /tmp;
autoindex on;
}
}
}
rtmp {
server {
listen 1935;
application src {
live on;
# exec_push /usr/bin/ffmpeg -f flv -analyzeduration 15000000 -probesize 200000 -i rtmp://localhost/src/$name -vcodec libx264 -vprofile baseline -g 10 -vf scale=240:-1 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_240/$name 2>>/var/log/nginx/ffmpeg_240-$name.log;
# exec_push /usr/bin/ffmpeg -f flv -analyzeduration 15000000 -probesize 200000 -i rtmp://localhost/src/$name -vcodec libx264 -vprofile baseline -g 10 -vf scale=360:-1 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_360/$name 2>>/var/log/nginx/ffmpeg_360-$name.log;
# exec_push /usr/bin/ffmpeg -f flv -analyzeduration 15000000 -probesize 200000 -i rtmp://localhost/src/$name -vcodec libx264 -vprofile baseline -g 10 -vf scale=480:-1 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_480/$name 2>>/var/log/nginx/ffmpeg_480-$name.log;
exec_push /usr/bin/ffmpeg -f flv -analyzeduration 15000000 -probesize 200000 -i rtmp://localhost/src/$name
-vcodec libx264 -vprofile baseline -g 10 -vf scale=240:-2 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_240/$name
-vcodec libx264 -vprofile baseline -g 10 -vf scale=360:-2 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_360/$name
-vcodec libx264 -vprofile baseline -g 10 -vf scale=480:-2 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_480/$name
-vcodec libx264 -vprofile baseline -g 10 -vf scale=720:-2 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_720/$name
-vcodec libx264 -vprofile baseline -g 10 -vf scale=1080:-2 -acodec aac -ar 44100 -ac 1 -f flv rtmp://localhost/hls_1080/$name
2>>/var/log/nginx/ffmpeg_multiple-$name.log;
}
application hls_240 {
live on;
hls on;
hls_path /tmp/hls_240;
hls_fragment 5s;
}
application hls_360 {
live on;
hls on;
hls_path /tmp/hls_360;
hls_fragment 5s;
}
application hls_480 {
live on;
hls on;
hls_path /tmp/hls_480;
hls_fragment 5s;
}
application hls_720 {
live on;
hls on;
hls_path /tmp/hls_720;
hls_fragment 5s;
}
application hls_1080 {
live on;
hls on;
hls_path /tmp/hls_1080;
hls_fragment 5s;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment