commit fdcafae6ed23935b4ff2b0bad5a4126223a201ed Author: alf Date: Sun Oct 23 18:49:28 2016 -0700 first commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4027caf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,79 @@ +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 + +EXPOSE 1935 +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 + +# 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 + +# Get nginx-rtmp module. +RUN cd /tmp && wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_VERSION}.tar.gz \ + && tar zxf v${NGINX_RTMP_VERSION}.tar.gz && rm v${NGINX_RTMP_VERSION}.tar.gz + +# Compile nginx with nginx-rtmp module. +RUN cd /tmp/nginx-${NGINX_VERSION} \ + && ./configure \ + --prefix=/opt/nginx \ + --add-module=/tmp/nginx-rtmp-module-${NGINX_RTMP_VERSION} \ + --conf-path=/opt/nginx/nginx.conf --error-log-path=/opt/nginx/logs/error.log --http-log-path=/opt/nginx/logs/access.log \ + --with-debug +RUN cd /tmp/nginx-${NGINX_VERSION} && make && make install + +# ffmpeg dependencies. +RUN apk add nasm yasm-dev lame-dev libogg-dev x264-dev libvpx-dev libvorbis-dev x265-dev freetype-dev libass-dev libwebp-dev rtmpdump-dev libtheora-dev opus-dev +RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories +RUN apk add --update fdk-aac-dev + +# Get ffmpeg source. +RUN cd /tmp/ && wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz \ + && tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz && rm 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 + +RUN cd /opt/ && tar cvzf /tmp/nginx.tar.gz nginx + +# Cleanup. +RUN rm -rf /var/cache/* /tmp/* + +# RUN mkdir /www/static +ADD nginx.conf /opt/nginx/nginx.conf +ADD static /www/static + +CMD ["/opt/nginx/sbin/nginx"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d466ae9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Alfred Gutierrez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f67f63 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# docker-nginx-rtmp diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..33f04aa --- /dev/null +++ b/nginx.conf @@ -0,0 +1,71 @@ +daemon off; + +error_log logs/error.log debug; + +events { + worker_connections 1024; +} + +rtmp { + server { + listen 1935; + chunk_size 4000; + + application encoder { + live on; + + exec ffmpeg -i rtmp://localhost:1935/encoder/$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 + -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 400k -f flv -g 30 -r 30 -s 426x240 -preset superfast -profile:v baseline rtmp://localhost:1935/hls/$name_240p528kbs + -c:a libfdk_aac -b:a 64k -c:v libx264 -b:v 200k -f flv -g 15 -r 15 -s 426x240 -preset superfast -profile:v baseline rtmp://localhost:1935/hls/$name_240p264kbs; + } + + application hls { + live on; + hls on; + hls_fragment_naming system; + hls_fragment 5s; + hls_path /opt/data/hls; + hls_nested on; + + hls_variant _720p2628kbs BANDWIDTH=2628000,RESOLUTION=1280x720; + hls_variant _480p1128kbs BANDWIDTH=1128000,RESOLUTION=854x480; + hls_variant _360p878kbs BANDWIDTH=878000,RESOLUTION=640x360; + hls_variant _240p528kbs BANDWIDTH=528000,RESOLUTION=426x240; + hls_variant _240p264kbs BANDWIDTH=264000,RESOLUTION=426x240; + } + } +} + +http { + server { + listen 80; + + location /hls { + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } + root /opt/data; + add_header Cache-Control no-cache; + add_header Access-Control-Allow-Origin *; + } + + location /stat { + rtmp_stat all; + rtmp_stat_stylesheet static/stat.xsl; + } + + location /static { + alias /www/static; + } + + location = /crossdomain.xml { + root /www/static; + default_type text/xml; + expires 24h; + } + } +} diff --git a/static/crossdomain.xml b/static/crossdomain.xml new file mode 100644 index 0000000..393b262 --- /dev/null +++ b/static/crossdomain.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/static/stat.xsl b/static/stat.xsl new file mode 100644 index 0000000..355453b --- /dev/null +++ b/static/stat.xsl @@ -0,0 +1,355 @@ + + + + + + + + + + + + + RTMP statistics + + + +
+ Generated by + nginx-rtmp-module , + nginx , + pid , + built   + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RTMP#clientsVideoAudioIn bytesOut bytesIn bits/sOut bits/sStateTime
Accepted: codecbits/ssizefpscodecbits/sfreqchan + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + live streams + + + + + + + + + + + + vod streams + + + + + + + + + + + + + #cccccc + #dddddd + + + + + + var d=document.getElementById('-'); + d.style.display=d.style.display=='none'?'':'none'; + return false + + + + [EMPTY] + + + + + +    + + + + + + + + + + + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + +
IdStateAddressFlash versionPage URLSWF URLDroppedTimestampA-VTime
+ + +
+ + + + + + + + + + + d + + + + h + + + + m + + + s + + + + + + + + + + + + + T + + + G + + + M + + K + + + + b + B + + /s + + + + + + active + idle + + + + + + + publishing + playing + + + + + + + + + #cccccc + #eeeeee + + + + + + + + http://apps.db.ripe.net/search/query.html?searchtext= + + whois + + + + + + + + + + + + + + + + + + + + + + + + + + publishing + + + + active + + + + x + + +