A nginx server with rtmp module for stream video in hls format.
Docker image for an RTMP/HLS server running on nginx
NGINX Version 1.21.1
nginx-rtmp-module Version 1.2.2
- Using a ready docker image
- Download the docker image nginx-rmtp-hls.tar
- Load this docker image in docker, open a console for that:
# docker load < nginx-rmtp-hls.tar
- List your docker images
# docker images
You will see:
REPOSITORY TAG IMAGE ID CREATED SIZE alcarazolabs/nginx-rtmp-hls latest f7749de13327 2 minutes ago 17.3MB
3.1 IF YOU DON'T WANT TO LOAD THIS file nginx-rmtp-hls.tar AND YOU WANT RUN IT ON RASPBERRY PI or BUILD THE DOCKER IMAGE. RUN:
# chmod +x run.sh # docker image build -t raspberrypi/nginx-rtmp-hls .
Note: In this case you should use the file Dockerfile-raspberrypi, rename this file and ignore the default Dockerfile.
4. Run the server:
docker run -p 1935:1935 -p 8080:8080 alcarazolabs/nginx-rtmp-hls
- Start Obs Studio and start a transmision
Streaming Service: Custom Server: rtmp://192.168.0.16:1935/live Play Path/Stream Key: mystream
- Watching the steam
In your favorite RTMP video player connect to the stream using the URL:
rtmp://192.168.0.16:8080/live/mystream
http://192.168.0.16:8080/hls/mystream.m3u8
This image exposes port 1935 for RTMP Steams and has 2 default channels open "live" and "testing".
live (or your first stream name) is also accessable via HLS on port 8080
It also exposes 8080 so you can access http://
The configuration file is in /opt/nginx/conf/
You can enable multiple streams on the container by setting RTMP_STREAM_NAMES when launching, This is a comma seperated list of names, E.G.
docker run \ -p 1935:1935 \ -p 8080:8080 \ -e RTMP_STREAM_NAMES=live,teststream1,teststream2 \ alcarazolabs/nginx-rtmp-hls
You can ush your main stream out to other RTMP servers, Currently this is limited to only the first stream in RTMP_STREAM_NAMES (default is live) by setting RTMP_PUSH_URLS when launching, This is a comma seperated list of URLS, EG:
docker run \ -p 1935:1935 \ -p 8080:8080 \ -e RTMP_PUSH_URLS=rtmp://live.youtube.com/myname/streamkey,rtmp://live.twitch.tv/app/streamkey alcarazolabs/nginx-rmtp-hls
- VLC
- Web HLS Player (https://github.com/alcarazolabs/rtmp-hls-player)
https://hub.docker.com/r/jasonrivers/nginx-rtmp
https://github.com/JasonRivers/Docker-nginx-rtmp
The ip 192.168.0.16 must be replace by your machine ip, this is an example ip.