Code Monkey home page Code Monkey logo

rtmp-hls-server's Introduction

RTMP-HLS Docker

Docker image for video streaming server that supports RTMP, HLS, and DASH streams.

Docker Automated build Build Status

Description

This Docker image can be used to create a video streaming server that supports RTMP, HLS, DASH out of the box. It also allows adaptive streaming and custom transcoding of video streams. All modules are built from source on Debian and Alpine Linux base images.

Features

  • The backend is Nginx with nginx-rtmp-module.
  • FFmpeg for transcoding and adaptive streaming.
  • Default settings:
    • RTMP is ON
    • HLS is ON (adaptive, 5 variants)
    • DASH is ON
    • Other Nginx configuration files are also provided to allow for RTMP-only streams or no-FFmpeg transcoding.
  • Statistic page of RTMP streams at http://<server ip>:<server port>/stats.
  • Available web video players (based on video.js and hls.js) at /usr/local/nginx/html/players.

Current Image is built using:

  • Nginx 1.17.5 (compiled from source)
  • Nginx-rtmp-module 1.2.1 (compiled from source)
  • FFmpeg 4.2.1 (compiled from source)

This image was inspired by similar docker images from tiangolo and alfg. It has small build size, adds support for HTTP-based streams and adaptive streaming using FFmpeg.

Usage

To run the server

docker run -d -p 1935:1935 -p 8080:8080 alqutami/rtmp-hls

For Alpine-based Image use:

docker run -d -p 1935:1935 -p 8080:8080 alqutami/rtmp-hls:latest-alpine

To run with custom conf file:

docker run -d -p 1935:1935 -p 8080:8080 -v custom.conf:/etc/nginx/nginx.conf alqutami/rtmp-hls

where custom.conf is the new conf file for Nginx.

To stream to the server

  • Stream live RTMP content to:

    rtmp://<server ip>:1935/live/<stream_key>
    

    where <stream_key> is any stream key you specify.

  • Configure OBS to stream content:
    Go to Settings > Stream, choose the following settings:

    • Service: Custom Streaming Server.
    • Server: rtmp://<server ip>:1935/live.
    • Stream key: anything you want, however provided video players assume stream key is test

To view the stream

  • Using VLC:

    • Go to Media > Open Network Stream.
    • Enter the streaming URL: rtmp://<server ip>:1935/live/<stream-key> Replace <server ip> with the IP of where the server is running, and <stream-key> with the stream key you used when setting up the stream.
    • For HLS and DASH, the URLs are of the forms: http://<server ip>:8080/hls/<stream-key>.m3u8 and http://<server ip>:8080/dash/<stream-key>_src.mpd respectively.
    • Click Play.
  • Using provided web players:
    The provided demo players assume the stream-key is called test and the player is opened in localhost.

    • To play RTMP content (requires Flash): http://localhost:8080/players/rtmp.html
    • To play HLS content: http://localhost:8080/players/hls.html
    • To play HLS content using hls.js library: http://localhost:8080/players/hls_hlsjs.html
    • To play DASH content: http://localhost:8080/players/dash.html
    • To play RTMP and HLS contents on the same page: http://localhost:8080/players/rtmp_hls.html

    Notes:

    • These web players are hardcoded to play stream key "test" at localhost.
    • To change the stream source for these players. Download the html files and modify the src attribute in the video tag in the html file. You can then mount the modified files to the container as follows:
       docker run -d -p 1935:1935 -p 8080:8080 -v custom_players:/usr/local/nginx/html/players alqutami/rtmp-hls
      
      where custom_players is the directory holding the modified html files.

Copyright

Released under MIT license.

More info

rtmp-hls-server's People

Contributors

dunn avatar dv4mp1r3 avatar matho avatar tareqalqutami avatar v0l avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtmp-hls-server's Issues

High delay?

Just started testing around with it and i seem to have around 60 second or more delay. Is there anyway to lower this?

No logs for incoming rtmp connections to say what went wrong

I don't see any logs at all for connections on the 1935 port. It doesn't log it started/stopped/failed anything at all in the logs. Is it supposed to? Is there something I can add so it does log something? Right now it is disconnecting immediately and not saying why.

How to use adaptive quality?

Hello. How do I can use adaptive streaming with HLS?

hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution
hls_variant _hd720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution
hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution

Audio only in HLS, nothing in DASH - using NVENC

Hello

Trying to set this up.
I'm sending from OBS in rtmp successully.
I can open the rtmp stream in VLC .

When loading the HLS player i'm getting audio only, black video.
in dash the spinner is just spinning endlessly.

/stats gives this ;
`

RTMP #clients Video Audio In bytes Out bytes In bits/s Out bits/s State Time
Accepted: 21 199.71 MB 155.95 MB 2.91 Mb/s 567 Kb/s   9m 55s
live
live streams 2
test 2 H264 High 4.0 2.23 Mb/s 1920x1080 30 AAC LC 126 Kb/s 48000 2
show
live streams 5
test_hd720 1   0 Kb/s 0x0 0 AAC LC 198 Kb/s 48000 2
test_src 1   0 Kb/s 0x0 0 AAC LC 197 Kb/s 48000 2
test_mid 1   0 Kb/s 0x0 0 AAC LC 198 Kb/s 48000 2
test_high 1   0 Kb/s 0x0 0 AAC LC 198 Kb/s 48000 2
test_low 1   0 Kb/s 0x0 0 AAC LC 100 Kb/s 48000 2

`

Loss of Video and/or entire stream

I'd dearly love to get this docker working correctly. However there are a couple of issues.

First, it will randomly drop the video or the entire stream. Looking at the stats, the video is not present. A stop start of the docker plugin resolves. This can happen frequently within an hour

rtmp
rtmp2

Secondly, sometimes the stats page shows nothing.. even though the plugin is outputting a stream and I am viewing it on another device.

Another issue is when starting up the docker plugin, the syslog is flooded with these messages (eventually filling up all the log space). These messages continue until the docker plugin is stopped. This could be related to the above issue

Mar 12 15:04:05 Miley kernel: device br0 entered promiscuous mode
Mar 12 15:04:12 Miley kernel: tun: unexpected GSO type: 0x0, gso_size 1460, hdr_len 1514
Mar 12 15:04:12 Miley kernel: tun: c8 92 3f 88 49 d4 43 2e de 65 d4 cc f1 3d d6 b8 ..?.I.C..e...=..
Mar 12 15:04:12 Miley kernel: tun: 73 21 37 9b b0 ba 27 4e 46 7b 67 bf 42 52 bf 51 s!7...'NF{g.BR.Q
Mar 12 15:04:12 Miley kernel: tun: 99 da 86 ec c1 15 e7 04 85 8b 96 51 4a 41 36 3d ...........QJA6=
Mar 12 15:04:12 Miley kernel: tun: a2 22 65 63 1e 6a f4 4b cf 25 70 e8 15 6d b2 e8 ."ec.j.K.%p..m..

Cheers,
Grant

How to change stream key 'test'?

Good afternoon, I'm trying to change the default stream key, and when I change it in loadsource it doesn't work for me, they say that you have to change it in the src tag of the video, but there is nothing there
Captura de pantalla 2023-07-05 205537

I am changing the stream key in the loadSource
image

But when it comes to playing, it doesn't load the stream, and yes, I also put the new stream key in the obs

HLS issues

I was configured my OBS as custom streaming to rtmp://<ip>:<port>/stream and key test

As I understood, nginx will callback ffmpeg to block the stream into .ts for HLS, however it is not working.

image

And here's the nginx's log

image

rtsp to rtmp

im using your code and docker image it works in the default setup , so i changed little in nginx.conf

but i want to get live feed from rtsp cam so i tried to modify it but i cant to create the stream files for hls or dash
any hints?

worker_processes auto;
error_log /var/log/nginx/nginx_error.log;

events {
worker_connections 1024;
}

RTMP configuration

rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
# ping 30s;
# notify_method get;

	# This application is to accept incoming stream
	application live {
		live on; # Allows live input
        interleave on;

		# for each received stream, transcode for adaptive streaming
		# This single ffmpeg command takes the input and transforms
		# the source into 4 different streams with different bitrates
		# and qualities. # these settings respect the aspect ratio.
		#exec_push  /usr/local/bin/ffmpeg -i rtmp://localhost:1935/$app/$name -async 1 -vsync -1
		#			-c:v libx264 -c:a aac -b:v 256k  -b:a 64k -vf "scale=480:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_low
		#			-c:v libx264 -c:a aac -b:v 768k  -b:a 64k -vf "scale=720:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_mid
		#			-c:v libx264 -c:a aac -b:v 1024k -b:a 64k -vf "scale=960:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_high
		#			-c:v libx264 -c:a aac -b:v 1920k -b:a 64k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_hd720
		#			-c copy -f flv rtmp://localhost:1935/show/$name_src;			
        #

        exec_static /usr/local/bin/ffmpeg -i rtsp://mydomain.com:554/media/video1 -c copy -an -f flv rtmp://localhost:1935/live/cam >> /var/log/ffmpeg.log;
		drop_idle_publisher 10s; 
	

	# This is the HLS application
	#application show {
	#	live on; # Allows live input from above application
		#deny play all; # disable consuming the stream from nginx as rtmp
		
		hls on; # Enable HTTP Live Streaming
		hls_fragment 3;
		hls_playlist_length 20;
		hls_path /mnt/hls/;  # hls fragments path
		# Instruct clients to adjust resolution according to bandwidth
		#hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution
		#hls_variant _hd720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution
		#hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
		#hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
		#hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
		
		# MPEG-DASH
        dash on;
        dash_path /mnt/dash/;  # dash fragments path
		dash_fragment 3;
		dash_playlist_length 20;			
	}
}

}

http {
access_log /var/log/nginx/nginx_access.log;
sendfile off;
tcp_nopush on;
directio 512;
# aio on;

# HTTP server required to serve the player and HLS fragments
server {
	listen 8080;
	
	# Serve HLS fragments
	location /hls {
		types {
			application/vnd.apple.mpegurl m3u8;
			video/mp2t ts;
		}
		
		root /mnt;

        add_header Cache-Control no-cache; # Disable cache
		
		# CORS setup
		add_header 'Access-Control-Allow-Origin' '*' always;
		add_header 'Access-Control-Expose-Headers' 'Content-Length';
        
		# allow CORS preflight requests
		if ($request_method = 'OPTIONS') {
			add_header 'Access-Control-Allow-Origin' '*';
			add_header 'Access-Control-Max-Age' 1728000;
			add_header 'Content-Type' 'text/plain charset=UTF-8';
			add_header 'Content-Length' 0;
			return 204;
		}
	}
	
    # Serve DASH fragments
    location /dash {
        types {
            application/dash+xml mpd;
            video/mp4 mp4;
        }

		root /mnt;
		
		add_header Cache-Control no-cache; # Disable cache


        # CORS setup
        add_header 'Access-Control-Allow-Origin' '*' always;
        add_header 'Access-Control-Expose-Headers' 'Content-Length';

        # Allow CORS preflight requests
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
    }		
	
	# This URL provides RTMP statistics in XML
	location /stat {
		rtmp_stat all;
		rtmp_stat_stylesheet stat.xsl; # Use stat.xsl stylesheet 
	}

	location /stat.xsl {
		# XML stylesheet to view RTMP stats.
		root /usr/local/nginx/html;
	}

}

}

EXTINF:8.33 in converted hls parts

Could you please help me to decrease EXTINF in converted with ffmpeg hls fragments?
I stream with 2 seconds per fragment, so _src.m3u8 have these strings (everything is great):

#EXTINF:2.000,
my_stream_src-8.ts
#EXTINF:2.000,
my_stream_src-9.ts
#EXTINF:2.000,
my_stream_src-10.ts
#EXTINF:2.000,
my_stream_src-11.ts
#EXTINF:2.000,
my_stream_src-12.ts
#EXTINF:2.000,
my_stream_src-13.ts

However hd720, mid and etc. parts seems to be 8 seconds long:

#EXTINF:8.334,
my_stream_hd720-22.ts
#EXTINF:8.333,
my_stream_hd720-23.ts
#EXTINF:8.333,
my_stream_hd720-24.ts
#EXTINF:8.334,
my_stream_hd720-25.ts
#EXTINF:8.333,
my_stream_hd720-26.ts
#EXTINF:8.333,
my_stream_hd720-27.ts

This increases the delay of stream, download speed and etc.
Any advice would be appreciated greatly.
Command for converting:

exec_push  /usr/local/bin/ffmpeg -i rtmp://localhost:1935/$app/$name -async 1 -vsync -1
			-c:v libx264 -c:a aac -b:v 768k  -b:a 128k -vf "scale=720:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_mid
			-c:v libx264 -c:a aac -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_hd720
			-c copy -f flv rtmp://localhost:1935/show/$name_src;

Server keeps disconnecting from OBS?

Clean install of OBS 25.0.8 on a clean windows 10 install. I setup the rtmp server with a docker on unraid. What's so weird is when I tell OBS to do a "test stream" from it's auto setup wizard, it actually works, for the duration of the test I can go into the status page and see it creating all the hls streams. But then using those same settings (on multiple systems, both using QSV and NVENC) it just disconnects the stream right away and the stat page is empty. When checking the docker logs I see the test was sucessful

24.205.146.34 [19/Jun/2020:23:56:41 -0700] PUBLISH "live" "test" "" - 15524229 529 "" "FMLE/3.0 (compatible; FMSc/1.0)" (12s)
2020/06/19 23:56:41 [alert] 7#7: unknown process 343 exited on signal 9
127.0.0.1 [19/Jun/2020:23:56:41 -0700] PUBLISH "show" "test_src" "" - 6370909 409 "" "" (11s)
127.0.0.1 [19/Jun/2020:23:56:41 -0700] PUBLISH "show" "test_hd720" "" - 9799384 409 "" "" (11s)
127.0.0.1 [19/Jun/2020:23:56:41 -0700] PUBLISH "show" "test_high" "" - 6099812 409 "" "" (11s)
127.0.0.1 [19/Jun/2020:23:56:41 -0700] PUBLISH "show" "test_mid" "" - 4000107 409 "" "" (11s)
127.0.0.1 [19/Jun/2020:23:56:41 -0700] PUBLISH "show" "test_low" "" - 2219004 409 "" "" (11s)
127.0.0.1 [19/Jun/2020:23:56:41 -0700] PLAY "live" "test" "" - 376 12855488 "" "" (12s)

But when trying to stream and getting the disconnect no errors show up in the docker log, where can I probe for a log file that might point out where the issue is?

Thanks

How to reduce latency?

I streamed OBS to the standard install. From safari, I browse to the hls.html. The stream comes up lovely and clear but it’s about a minute behind what is on OBS. What are the main issues causing this? Is there a buffer setting that needs changing or something.

Can anyone advise how to get the HLS stream a lot closer to live please?

Build Issues [RTMP]

I am unable to get this to build on Alpine versions above 3.8. I have also tested Debian buster with similar result; but would like to focus on Alpine.

It seems like a dependency might be missing; but I've checked and believe I have all the correct dependencies. At least, its consistent with other builds.

Note: Adding linux-headers did not make a difference; build still fails.

Does anyone know why RTMP would fail to build on newer versions of both Alpine and Debian?

RUN apk update  && \
        apk --no-cache add \
                bash build-base ca-certificates \
                openssl openssl-dev make  \
                gcc libgcc libc-dev rtmpdump-dev \
                zlib-dev musl-dev pcre pcre-dev \
                yasm pkgconf pkgconfig libtheora-dev \
                libvorbis-dev libvpx-dev freetype-dev  \
                x264-dev x265-dev 

Tested

  • Alpine 3.9
  • Alpine 3.10
  • Alpine 3.11

Tested

  • Nginx 1.17.5
  • Nginx 1.17.6
  • Nginx 1.17.7
  • Nginx 1.17.8
  • Nginx 1.17.9
  • Nginx 1.17.10
  • Nginx 1.18.0

All Nginx builds work if using Apline 3.8

The build always fails on the RTMP module.

/tmp/build/nginx-rtmp-module-1.2.1/ngx_rtmp_eval.c: In function 'ngx_rtmp_eval':
/tmp/build/nginx-rtmp-module-1.2.1/ngx_rtmp_eval.c:160:17: error: this statement may fall through [-Werror=implicit-fallthrough=]
                 switch (c) {
                 ^~~~~~
/tmp/build/nginx-rtmp-module-1.2.1/ngx_rtmp_eval.c:170:13: note: here
             case ESCAPE:
             ^~~~
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:1386: objs/addon/nginx-rtmp-module-1.2.1/ngx_rtmp_eval.o] Error 1
make[1]: Leaving directory '/tmp/build/nginx-1.18.0'
make: *** [Makefile:8: build] Error 2
The command '/bin/sh -c cd /tmp/build/nginx-${NGINX_VERSION} &&     ./configure         --sbin-path=/usr/local/sbin/nginx         --conf-path=/etc/nginx/nginx.conf         --error-log-path=/var/log/nginx/error.log         --http-log-path=/var/log/nginx/access.log         --pid-path=/var/run/nginx/nginx.pid         --lock-path=/var/lock/nginx.lock         --http-client-body-temp-path=/tmp/nginx-client-body         --with-http_ssl_module         --with-threads         --add-module=/tmp/build/nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION} &&     make -j $(getconf _NPROCESSORS_ONLN) &&     make install' returned a non-zero code: 2

Not Working

Hi

Has somthing changed. I have tried two machines (Both Macs) running this. Whilst OBS seems to think its streaming to the server there is no output.

Any troubleshooting you would suggest?

Thanks

JT

Audio quality appears capped at 128k

The aac code doesn't appear to be able to be configured to do more, can we have more audio codecs, such as libmp3lame or something else. I am new to this, but I hope my thoughts find you well. Thank you for this tool, I'm just hoping to really maximize my available bandwidth.

how to enable user pass for OBS?

Hi dear!
I need to set a user pass for my specific stream key to restrict others to access my stream key.
How can I enable authorization??

error 405 when streaming in DASH or HLS

Hello,

I'm unable to stream to the nginx server whatever the format (DASH, or HLS) : A 405 error is raised for the PUT request
Docker logs :
172.29.31.13 - - [15/Dec/2020:16:44:00 +0000] "PUT /hls/file-TL_11-6.m3u8 HTTP/1.1" 405 157 "-" "v4.1"
172.29.31.13 - - [15/Dec/2020:16:44:00 +0000] "PUT /dash/audio-TL_11-6-24000-160805064.mp4a HTTP/1.1" 405 157 "-" "v4.1"

share my screen

Hi,

Thanks for the package it is easy to install and works well.

The aim was to use this to just share my desktop to others using OBS. However when I watch the stream on the web players or on VLC it doesn't show the live stream but a slightly out of date one.

I don't want to save any video to the server. I just want a live stream that shows only the latest. Otherwise it won't make any sense to anyone. Is there any way to do that?

How to run on Raspberry Pi 4 with OpenWrt

Hi,
your Docker container is exactly what I'm looking for 🤩 My project is to have a Raspberry Pi 4 as a wireless Accesspoint running a Streaming-Server so that I can stream a drone video live onto multiple devices.

For the Access Point I'm using OpenWRT (as Raspian was not reliable with an external wifi-antenna). I got docker set up for OpenWrt however when I try to run the container via
docker run --platform linux/arm64 -d -p 1935:1935 -p 8080:8080 alqutami/rtmp-hls
after the download I gt this message back:
WARNING: image with reference alqutami/rtmp-hls was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64 docker: Error response from daemon: image with reference alqutami/rtmp-hls was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64.

What must I do to get it up and running?

Thanks a lot in advance! :)

stops streaming/ playing the stream after around 7 min

hellu any hints on why it s just stops stream after 5-7 min

my nginx conf
worker_processes auto;
error_log /var/log/nginx/nginx_error.log;

events {
worker_connections 1024;
}

RTMP configuration

rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
# ping 30s;
# notify_method get;

	# This application is to accept incoming stream
	application live {
		live on; # Allows live input
        interleave on;

		# for each received stream, transcode for adaptive streaming
		# This single ffmpeg command takes the input and transforms
		# the source into 4 different streams with different bitrates
		# and qualities. # these settings respect the aspect ratio.
		#exec_push  /usr/local/bin/ffmpeg -i rtmp://localhost:1935/$app/$name -async 1 -vsync -1
		#			-c:v libx264 -c:a aac -b:v 256k  -b:a 64k -vf "scale=480:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_low
		#			-c:v libx264 -c:a aac -b:v 768k  -b:a 64k -vf "scale=720:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_mid
		#			-c:v libx264 -c:a aac -b:v 1024k -b:a 64k -vf "scale=960:trunc(ow/a/2)*2"  -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_high
		#			-c:v libx264 -c:a aac -b:v 1920k -b:a 64k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset superfast -crf 23 -f flv rtmp://localhost:1935/show/$name_hd720
		#			-c copy -f flv rtmp://localhost:1935/show/$name_src;			
        #

;
## Reolink cam
exec_static /usr/local/bin/ffmpeg -i rtsp://ip//h264Preview_01_main -c copy -b:a 64k -f flv rtmp://localhost:1935/live/std;

		drop_idle_publisher 10s; 
	

	# This is the HLS application
	#application show {
	#	live on; # Allows live input from above application
		#deny play all; # disable consuming the stream from nginx as rtmp
		
		hls on; # Enable HTTP Live Streaming
		#hls_fragment 3;
		hls_playlist_length 20;
		hls_fragment            5s;
		       hls_path /mnt/hls/;  # hls fragments path
		# Instruct clients to adjust resolution according to bandwidth
		#hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution
		#hls_variant _hd720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution
		#hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
		#hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
		#hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
		
		# MPEG-DASH
        dash on;
        dash_path /mnt/dash/;  # dash fragments path
		dash_fragment 3;
		dash_playlist_length 20;			
	}
}

}

http {
access_log /var/log/nginx/nginx_access.log;
sendfile off;
tcp_nopush on;
directio 512;
# aio on;

# HTTP server required to serve the player and HLS fragments
server {
	listen 8080;
	
	# Serve HLS fragments
	location /hls {
		types {
			application/vnd.apple.mpegurl m3u8;
			video/mp2t ts;
		}
		
		root /mnt;

        add_header Cache-Control no-cache; # Disable cache
		
		# CORS setup
		add_header 'Access-Control-Allow-Origin' '*' always;
		add_header 'Access-Control-Expose-Headers' 'Content-Length';
        
		# allow CORS preflight requests
		if ($request_method = 'OPTIONS') {
			add_header 'Access-Control-Allow-Origin' '*';
			add_header 'Access-Control-Max-Age' 1728000;
			add_header 'Content-Type' 'text/plain charset=UTF-8';
			add_header 'Content-Length' 0;
			return 204;
		}
	}
	
    # Serve DASH fragments
    location /dash {
        types {
            application/dash+xml mpd;
            video/mp4 mp4;
        }

		root /mnt;
		
		add_header Cache-Control no-cache; # Disable cache


        # CORS setup
        add_header 'Access-Control-Allow-Origin' '*' always;
        add_header 'Access-Control-Expose-Headers' 'Content-Length';

        # Allow CORS preflight requests
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
    }		
	
	# This URL provides RTMP statistics in XML
	location /stat {
		rtmp_stat all;
		rtmp_stat_stylesheet stat.xsl; # Use stat.xsl stylesheet 
	}

	location /stat.xsl {
		# XML stylesheet to view RTMP stats.
		root /usr/local/nginx/html;
	}

}

}

HLS + HTTPS

What is the best approach to get HLS working over HTTPS in Docker on AWS EC2?

Adaptive Streaming

Hi,

first of all its a really nice docker container you made! Thx anyway!

Should it be possible to get streams with vlc rtmp://localhost:1935/show/test_hd720 as well?
Its not working in my setup.

Or how can I use all this *_mid, *_hight, *_low ...etc?

How can I test this adaptive Streaming? Where are this _ streams used?

Thanks and have a nice day
Darian

Add drop_idle_publisher 10s; to conf

I would recommend adding the drop_idle_publisher 10s; after the exec push to the nginx conf to prevent errors when the stream publisher has network issues.

How to reproduce:
Stream to nginx via OBS and pull network cable of your streaming device. When reconnecting you cannot stream to the same Streamkey. error_log says: live: already publishing.

The above directive fixes this problem.

Allowlist/whitelist of stream keys

Hi,

i got everything running for a while now and i used to use a IP whitelist who can access port 1935 in my firewall to have some control on who can use my stream server and who cant. Now we would also go "outside" our normal streaming environment and we will be using 4G/5G to stream. There is chance the WAN IP will change alot. So i wanted to generate unique stream keys for my users to allow them to stream from everywhere. I know there is a 'notify" option in nginx is could use for this, but this is also where my knowledge stops.

i hope someone has experience with this and could help me.

Kind regards,
Graxo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.