From 5c76430142f016cba2a4f7ecb91c621b17ef8cae Mon Sep 17 00:00:00 2001 From: alf Date: Sat, 5 Nov 2016 20:58:21 -0700 Subject: [PATCH] Update nginx url naming convention. Add alias. --- README.md | 8 ++++---- nginx.conf | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index faade81..8bffd20 100644 --- a/README.md +++ b/README.md @@ -23,20 +23,20 @@ docker run -it -p 1935:1935 -p 8080:80 --rm nginx-rtmp * Stream live content to: ``` -rtmp://:1935/encoder/$STREAM_NAME +rtmp://:1935/stream/$STREAM_NAME ``` ### OBS Configuration * Stream Type: `Custom Streaming Server` -* URL: `rtmp://localhost:1935/live` +* URL: `rtmp://localhost:1935/stream` * Stream Key: `hello` ### Watch Stream * In Safari, VLC or any HLS player, open: ``` -http://:8080/hls/$STREAM_NAME.m3u8 +http://:8080/live/$STREAM_NAME.m3u8 ``` -* Example: `http://localhost:8080/hls/hello` +* Example: `http://localhost:8080/live/hello` ### FFmpeg Build diff --git a/nginx.conf b/nginx.conf index 89fc412..c9ebd0c 100644 --- a/nginx.conf +++ b/nginx.conf @@ -11,10 +11,10 @@ rtmp { listen 1935; chunk_size 4000; - application live { + application stream { live on; - exec ffmpeg -i rtmp://localhost:1935/live/$name + exec ffmpeg -i rtmp://localhost:1935/stream/$name -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1280x720 -preset superfast -profile:v baseline rtmp://localhost:1935/hls/$name_720p2628kbs -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 1000k -f flv -g 30 -r 30 -s 854x480 -preset superfast -profile:v baseline rtmp://localhost:1935/hls/$name_480p1128kbs -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 750k -f flv -g 30 -r 30 -s 640x360 -preset superfast -profile:v baseline rtmp://localhost:1935/hls/$name_360p878kbs @@ -53,6 +53,16 @@ http { add_header Access-Control-Allow-Origin *; } + location /live { + alias /opt/data/hls; + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } + add_header Cache-Control no-cache; + add_header Access-Control-Allow-Origin *; + } + location /stat { rtmp_stat all; rtmp_stat_stylesheet static/stat.xsl;