Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example to serve the RTMP stream over HLS. #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL maintainer="Sebastian Ramirez <[email protected]>"

# Versions of Nginx and nginx-rtmp-module to use
ENV NGINX_VERSION nginx-1.18.0
ENV NGINX_RTMP_MODULE_VERSION 1.2.1
ENV NGINX_RTMP_MODULE_VERSION 1.2.2

# Install dependencies
RUN apt-get update && \
Expand Down Expand Up @@ -51,6 +51,10 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log && \

# Set up config file
COPY nginx.conf /etc/nginx/nginx.conf
RUN mkdir -p /tmp/hls/live

# RTMP
EXPOSE 1935
# HLS
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
42 changes: 41 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
worker_processes auto;
rtmp_auto_push on;
events {}

# See https://github.com/arut/nginx-rtmp-module for details.
rtmp {
server {
listen 1935;
listen [::]:1935 ipv6only=on;
listen [::]:1935 ipv6only=on;

application live {
live on;
record off;

# record first 1K of stream
#record all;
#record_path /tmp/av;
#record_max_size 1K;

# append current timestamp to each flv
#record_unique on;

# publish only from localhost
#allow publish 127.0.0.1;
#deny publish all;

# this is the default, allow everyone to play
#allow play all;

# see http section related
hls on;
hls_path /tmp/hls/live;
hls_type live;
hls_fragment 5s;
hls_playlist_length 15s;
}
}
}

http {
server {
listen 8080;

location /live {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp/hls;
add_header Cache-Control no-cache;
}
}
}