Skip to content

Instantly share code, notes, and snippets.

@WoonHaKim
Created October 12, 2018 01:51
Show Gist options
  • Save WoonHaKim/1a2b1bab9a2b400f51d5c6890bd60174 to your computer and use it in GitHub Desktop.
Save WoonHaKim/1a2b1bab9a2b400f51d5c6890bd60174 to your computer and use it in GitHub Desktop.
nginx-rtmp config example
rtmp {
server{
listen 1935;
chunk_size 256;
buflen 100ms;
application live {
live on;
# dash on;
# dash_path /tmp/dash;
# dash_fragment 1s;
exec /usr/local/bin/ffmpeg -re -i rtmp://localhost/live/$name -async 1 -vsync -1 -threads 4
-c:a libfdk_aac -b:a 32k -c:v libx264 -b:v 256K -tune zerolatency -preset fast -f flv rtmp://localhost/hls/$name_low
-c:a libfdk_aac -b:a 96k -c:v libx264 -b:v 768k -tune zerolatency -preset fast -f flv rtmp://localhost/hls/$name_mid
-c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 1024K -tune zerolatency -preset fast -f flv rtmp://localhost/hls/$name_hi
-c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 1920K -tune zerolatency -preset fast -f flv rtmp://localhost/hls/$name_hd720
-c copy -f flv rtmp://localhost/hls/$name_src;
}
http {
# See http://licson.net/post/optimizing-nginx-for-large-file-delivery/ for more detail
# This optimizes the server for HLS fragment delivery
sendfile off;
tcp_nopush on;
directio 512;
server{
listen 8090;
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache; # Prevent caching of HLS fragments
add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
}
# location /dash {
# root /tmp;
# add_header Cache-Control no-cache; # Prevent caching of HLS fragments
# add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
# }
}
server{
listen 8090;
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache; # Prevent caching of HLS fragments
add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
}
# location /dash {
# root /tmp;
# add_header Cache-Control no-cache; # Prevent caching of HLS fragments
# add_header Access-Control-Allow-Origin *; # Allow web player to access our playlist
# }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment