RTMP to HLS - Zibbp/Radium GitHub Wiki
An RTMP stream can be converted to HLS using Nginx with VOD capabilities
Q: Why a RTMP livestream versus ffmpeg?
A: Easy, fast, and of course live.
Below is a guide of setting up a docker container that converts an RTMP stream into HLS media with VOD capabilities. The container will only output the resoultion being inputed. It will not convert into lower resolutions. If you would like to accomplish that and make use of HLS' adapative bittrate, I would suggest looking at this github repository https://github.com/alfg/docker-nginx-rtmp.
Getting Started
If only having one resolution is fine with your needs, I maintain a repository and docker container that does such.
https://github.com/Zibbp/Nginx-RTMP-HLS
https://hub.docker.com/repository/docker/zibbp/nginx-rtmp-hls
Docker command
docker run -d --name=rtmp-hls -p 1935:1935 -p 7080:7080 zibbp/nginx-rtmp-hls:latest
-p 1935:1935
Exposes the rtmp port
-p 7080:7080
Exposes the HTTP port
OPTIONAL
An environment variable can be added to expose a directory in the container allowing an hls stream to be served by the container such as when using FFMPEG to create HLS media.
-v /my/dir:/www/static
Once the container it deployed, upload your HLS files to that mounted directory and access them using the URL below. The path of the static directory is
http://IP:7080/static/FILENAME.m3u8
If using a reverse proxy
https://media.website.com/static/FILENAME.m3u8
Usage
Start by pushing a RTMP stream to the container using OBS, ffmpeg, etc.
Server: rtmp://IP:1935/hls
Stream Key: secret123
After starting a stream the HLS output can be found at
http://IP:7080/hls/STREAMKEY.m3u8
If using a reverse proxy
https://media.website.com/hls/STREAMKEY.m3u8
The URL can then be entered as a docker variable or within the Advanced Controls section below the player.
It is strongly suggested to put the HTTP server (port 7080) behind a reverse proxy with SSL so your HLS media is served securely.
Notes:
- The VOD (video on demand) is only kept for 3 hours. If you would like to change it, edit the
nginx.conf
in the repository and rebuild the docker container.