Skip to content

Athlon1600/nginx-rtmp-server

Repository files navigation

Video Streaming Server

GitHub last commit GitHub Actions Workflow Status Top language

Self-host your own streaming server without relying on any external and expensive services (like Amazon IVS).

See a demo here - https://demo.streamplanet.tv/

🐳 Requirements

All you need is Docker.
On Linux, you can install it with just this one-liner:

bash <(wget -O - https://raw.githubusercontent.com/Athlon1600/nginx-rtmp-server/master/install.sh)

🚀 Deployment

Whether you are playing with this on your local computer, or hosting it on a real server, the steps are basically the same.
Things do change a lot once you actually get thousands of users though.

Start by cloning this repository, and then start the services using Docker:

git clone https://github.com/Athlon1600/nginx-rtmp-server.git
cd nginx-rtmp-server
docker-compose up --build -d

and that is it!

Assuming you are doing this from your local computer, that should launch two services:

  • HTTP Nginx Server on port 8090: http://localhost:8090
  • RTMP Ingest Server on port 1935: rtmp://localhost:1935

Usage

Once the two services are up and running, you can now start streaming to your newly launched RTMP server at this endpoint:

rtmp://localhost:1935/live/{stream_key}

{stream_key} can be anything you want. In all the examples below we will be using test.

If you are using OBS, point your streaming settings to:

rtmp://localhost:1935/live/test

OBS Stream Settings

otherwise, you can just stream any mp4-like video file using ffmpeg:

ffmpeg -stream_loop -1 -nostdin -re -i "video.mp4" -copy -f flv rtmp://localhost/live/test

Your stream is now ready to be consumed via HTTP as .m3u8 playlist by any supporting client such as VLC Media Player:

  • Media -> Open Network Stream -> Network
  • Paste the link there:
http://localhost:8090/hls/test/master.m3u8
VLC Media Player Open Network Stream VLC Media Player Network URL

or you can embed that video stream on your website by using hls.js Javascript library:

Technical Notes

Powered by RTMP module for nginx.
https://www.nginx.com/products/nginx/modules/rtmp-media-streaming/

The original codebase stopped receiving updates years ago:
https://github.com/arut/nginx-rtmp-module

so we will be using this fork instead:
https://github.com/sergey-dryabzhinsky/nginx-rtmp-module

Projects using this library

Links