-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updating Cuda build to use 11.1. * Update Cuda build and add more resources to docs.
- Loading branch information
Showing
3 changed files
with
129 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,9 @@ RUN cd /tmp/nginx-${NGINX_VERSION} && \ | |
|
||
############################### | ||
# Build the FFmpeg-build image. | ||
FROM nvidia/cuda:10.2-devel-ubuntu18.04 as build-ffmpeg | ||
FROM nvidia/cuda:11.1-devel-ubuntu20.04 as build-ffmpeg | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ARG FFMPEG_VERSION | ||
ARG PREFIX=/usr/local | ||
ARG MAKEFLAGS="-j4" | ||
|
@@ -105,25 +107,16 @@ RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \ | |
--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-postproc \ | ||
--enable-avresample \ | ||
--enable-libfreetype \ | ||
--enable-openssl \ | ||
--enable-libnpp \ | ||
--enable-cuda \ | ||
--enable-cuvid \ | ||
--enable-nvenc \ | ||
--enable-libnpp \ | ||
--disable-debug \ | ||
--disable-doc \ | ||
--disable-ffplay \ | ||
--enable-cuda-nvcc \ | ||
--enable-libnpp \ | ||
--extra-cflags=-I/usr/local/cuda/include \ | ||
--extra-ldflags=-L/usr/local/cuda/lib64 \ | ||
--extra-libs="-lpthread -lm" && \ | ||
|
@@ -134,42 +127,38 @@ RUN rm -rf /var/cache/* /tmp/* | |
|
||
########################## | ||
# Build the release image. | ||
FROM nvidia/cuda:10.2-runtime-ubuntu18.04 | ||
LABEL MAINTAINER Haned Bahadorzadeh <[email protected]> | ||
FROM nvidia/cuda:11.1-runtime-ubuntu20.04 | ||
LABEL MAINTAINER Alfred Gutierrez <[email protected]> | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV NVIDIA_DRIVER_VERSION=455 | ||
ENV NVIDIA_VISIBLE_DEVICES all | ||
ENV NVIDIA_DRIVER_CAPABILITIES compute,video,utility | ||
|
||
# Set default ports. | ||
ENV HTTP_PORT 80 | ||
ENV HTTPS_PORT 443 | ||
ENV RTMP_PORT 1935 | ||
|
||
RUN apt update && apt install -y \ | ||
RUN apt update && apt install -y --no-install-recommends \ | ||
ca-certificates \ | ||
gettext \ | ||
openssl \ | ||
libpcre3 \ | ||
lame \ | ||
libogg0 \ | ||
libx264-152 \ | ||
libx265-146 \ | ||
curl \ | ||
libass9 \ | ||
libvpx5 \ | ||
libvorbis0a \ | ||
libwebp6 \ | ||
gettext \ | ||
libpcre3-dev \ | ||
libnvidia-decode-${NVIDIA_DRIVER_VERSION} \ | ||
libnvidia-encode-${NVIDIA_DRIVER_VERSION} \ | ||
libtheora0 \ | ||
libopus0 \ | ||
openssl \ | ||
rtmpdump | ||
|
||
COPY --from=build-nginx /usr/local/nginx /usr/local/nginx | ||
COPY --from=build-nginx /etc/nginx /etc/nginx | ||
COPY --from=build-ffmpeg /usr/local /usr/local | ||
COPY --from=build-ffmpeg /usr/lib/x86_64-linux-gnu/libfdk-aac.so /usr/lib/x86_64-linux-gnu/libfdk-aac.so | ||
COPY --from=build-ffmpeg /usr/lib/x86_64-linux-gnu/libfdk-aac.so.1 /usr/lib/x86_64-linux-gnu/libfdk-aac.so.1 | ||
|
||
# Add NGINX path, config and static files. | ||
ENV PATH "${PATH}:/usr/local/nginx/sbin" | ||
ENV HW_ACCEL "-hwaccel cuda -hwaccel_output_format cuda" | ||
ADD nginx.conf /etc/nginx/nginx.conf.template | ||
RUN sed -i "s/ffmpeg/ffmpeg ${HW_ACCEL}/g" /etc/nginx/nginx.conf.template | ||
ADD nginx-cuda.conf /etc/nginx/nginx.conf.template | ||
RUN mkdir -p /opt/data && mkdir /www | ||
ADD static /www/static | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
daemon off; | ||
|
||
error_log /dev/stdout info; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
rtmp { | ||
server { | ||
listen ${RTMP_PORT}; | ||
chunk_size 4000; | ||
|
||
application stream { | ||
live on; | ||
|
||
exec ffmpeg -hwaccel cuvid -c:v h264_cuvid -i rtmp://localhost:1935/stream/$name | ||
-c:a libfdk_aac -b:a 128k -c:v h264_nvenc -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 h264_nvenc -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 h264_nvenc -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 h264_nvenc -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 h264_nvenc -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 5; | ||
hls_playlist_length 10; | ||
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 { | ||
access_log /dev/stdout combined; | ||
|
||
ssl_ciphers HIGH:!aNULL:!MD5; | ||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | ||
ssl_session_cache shared:SSL:10m; | ||
ssl_session_timeout 10m; | ||
|
||
server { | ||
listen ${HTTP_PORT}; | ||
|
||
# Uncomment these lines to enable SSL. | ||
# Update the ssl paths with your own certificate and private key. | ||
|
||
# listen ${HTTPS_PORT} ssl; | ||
# ssl_certificate /opt/certs/example.com.crt; | ||
# ssl_certificate_key /opt/certs/example.com.key; | ||
|
||
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 /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; | ||
} | ||
|
||
location /static { | ||
alias /www/static; | ||
} | ||
|
||
location = /crossdomain.xml { | ||
root /www/static; | ||
default_type text/xml; | ||
expires 24h; | ||
} | ||
} | ||
} |