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; | |
} | |
} | |
} |
This comment has been minimized.
This comment has been minimized.
$name stands for the name of stream that you'll be publishing at rtmp://localhost/src/ (eg using ffmpeg: 'ffmpeg -i abc.mp4 -c:v copy -an -f flv rtmp://localhost/src/video1' when streamed $name will be 'video1') And 'src' is the name of application defined under rtmp block. (full path for rtmp stream ---> 'rtmp://server_ip:port/$app_name/$stream_name') Check this out for more info https://github.com/arut/nginx-rtmp-module/wiki/Directives. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Hello, sorry to bother you but I do not understand... How do you initialize the variable $name ?