From eff52a00de90336ab9450d116973fdab7f288a52 Mon Sep 17 00:00:00 2001 From: alf Date: Sun, 23 Oct 2016 19:17:32 -0700 Subject: [PATCH] minor updates. --- Dockerfile | 56 +++++++++++++++++++------------------- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ nginx.conf | 4 +-- 3 files changed, 109 insertions(+), 30 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4027caf..b944f77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ FROM alpine:latest MAINTAINER Alfred Gutierrez ENV NGINX_VERSION 1.9.15 -ENV FFMPEG_VERSION 3.0.2 ENV NGINX_RTMP_VERSION 1.1.10 +ENV FFMPEG_VERSION 3.0.2 EXPOSE 1935 EXPOSE 80 @@ -11,14 +11,14 @@ EXPOSE 80 RUN mkdir -p /opt/data && mkdir /www RUN apk update && apk add \ - gcc binutils-libs binutils build-base libgcc make pkgconf pkgconfig \ - openssl openssl-dev ca-certificates pcre \ - musl-dev libc-dev pcre-dev zlib-dev + gcc binutils-libs binutils build-base libgcc make pkgconf pkgconfig \ + openssl openssl-dev ca-certificates pcre \ + musl-dev libc-dev pcre-dev zlib-dev # Get nginx source. RUN cd /tmp && wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ - && tar zxf nginx-${NGINX_VERSION}.tar.gz \ - && rm nginx-${NGINX_VERSION}.tar.gz + && tar zxf nginx-${NGINX_VERSION}.tar.gz \ + && rm nginx-${NGINX_VERSION}.tar.gz # Get nginx-rtmp module. RUN cd /tmp && wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_VERSION}.tar.gz \ @@ -44,28 +44,28 @@ RUN cd /tmp/ && wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz # Compile ffmpeg. RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \ - ./configure \ - --enable-version3 \ - --enable-gpl \ - --enable-nonfree \ - --enable-small \ - --enable-libmp3lame \ - --enable-libx264 \ - --enable-libx265 \ - --enable-libvpx \ - --enable-libtheora \ - --enable-libvorbis \ - --enable-libopus \ - --enable-libfdk-aac \ - --enable-libass \ - --enable-libwebp \ - --enable-librtmp \ - --enable-postproc \ - --enable-avresample \ - --enable-libfreetype \ - --enable-openssl \ - --disable-debug \ - && make && make install && make distclean + ./configure \ + --enable-version3 \ + --enable-gpl \ + --enable-nonfree \ + --enable-small \ + --enable-libmp3lame \ + --enable-libx264 \ + --enable-libx265 \ + --enable-libvpx \ + --enable-libtheora \ + --enable-libvorbis \ + --enable-libopus \ + --enable-libfdk-aac \ + --enable-libass \ + --enable-libwebp \ + --enable-librtmp \ + --enable-postproc \ + --enable-avresample \ + --enable-libfreetype \ + --enable-openssl \ + --disable-debug \ + && make && make install && make distclean RUN cd /opt/ && tar cvzf /tmp/nginx.tar.gz nginx diff --git a/README.md b/README.md index 4f67f63..8e3a353 100644 --- a/README.md +++ b/README.md @@ -1 +1,80 @@ # docker-nginx-rtmp +A Dockerfile installing NGINX, nginx-rtmp-module and FFmpeg from source with +default settings for HLS live streaming. Built on Alpine Linux. + +* Nginx 1.9.15 (compiled from source) +* nginx-rtmp-module 1.1.10 (compiled from source) +* ffmpeg 3.0.2 (compiled from source) +* Default HLS settings (See: [nginx.conf](nginx.conf)) + +## Usage + +### Server +* Build and run container: +``` +docker build -t nginx-rtmp . +docker run -it -p 1935:1935 -p 8080:80 --rm nginx-rtmp +``` + +* Stream live content to: +``` +rtmp://:1935/encoder/$STREAM_NAME +``` + +### OBS Configuration +* Stream Type: `Custom Streaming Server` +* URL: `rtmp://localhost:1935/live` +* Stream Key: `hello` + +### Watch Stream +* In Safari, VLC or any HLS player, open: +``` +http://:8080/hls/$STREAM_NAME.m3u8 +``` +* Example: `http://localhost:8080/hls/hello` + + +### FFmpeg Build +``` +ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers + built with gcc 5.3.0 (Alpine 5.3.0) + configuration: --enable-version3 --enable-gpl --enable-nonfree --enable-small --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libopus --enable-libfdk-aac --enable-libass --enable-libwebp --enable-librtmp --enable-postproc --enable-avresample --enable-libfreetype --enable-openssl --disable-debug + libavutil 55. 17.103 / 55. 17.103 + libavcodec 57. 24.102 / 57. 24.102 + libavformat 57. 25.100 / 57. 25.100 + libavdevice 57. 0.101 / 57. 0.101 + libavfilter 6. 31.100 / 6. 31.100 + libavresample 3. 0. 0 / 3. 0. 0 + libswscale 4. 0.100 / 4. 0.100 + libswresample 2. 0.101 / 2. 0.101 + libpostproc 54. 0.100 / 54. 0.100 + + configuration: + --enable-version3 + --enable-gpl + --enable-nonfree + --enable-small + --enable-libmp3lame + --enable-libx264 + --enable-libx265 + --enable-libvpx + --enable-libtheora + --enable-libvorbis + --enable-libopus + --enable-libfdk-aac + --enable-libass + --enable-libwebp + --enable-librtmp + --enable-postproc + --enable-avresample + --enable-libfreetype + --enable-openssl + --disable-debug +``` + +## Resources +* https://alpinelinux.org/ +* http://nginx.org +* https://github.com/arut/nginx-rtmp-module +* https://www.ffmpeg.org +* https://obsproject.com diff --git a/nginx.conf b/nginx.conf index 33f04aa..89fc412 100644 --- a/nginx.conf +++ b/nginx.conf @@ -11,10 +11,10 @@ rtmp { listen 1935; chunk_size 4000; - application encoder { + application live { live on; - exec ffmpeg -i rtmp://localhost:1935/encoder/$name + exec ffmpeg -i rtmp://localhost:1935/live/$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