Sign inSign up

ido1990/nginx-rtmps

By ido1990

•Updated over 3 years ago

Image
0

333

ido1990/nginx-rtmps repository overview

⁠nginx-rtmps

Docker⁠ image with Nginx⁠ using the nginx-rtmp-module⁠ module for streaming and Stunnel⁠ to add TLS encryption functionality.

⁠Description

This Docker⁠ image can be used to create an RTMP server for multimedia / video streaming using Nginx⁠, nginx-rtmp-module⁠ and Stunnel⁠, built from the current latest sources (Nginx 1.18.0 , nginx-rtmp-module 1.2.1 and Stunnel 4).

This was inspired by other similar previous images from tiangolo⁠, dvdgiessen⁠, jasonrivers⁠, aevumdecessus⁠ and by an OBS Studio post⁠.

The main purpose (and test case) to build it was to allow streaming from OBS Studio⁠ to different clients at the same time.

GitHub repo: https://github.com/ido1990/nginx-rtmps⁠

Docker Hub image: https://hub.docker.com/r/ido1990/nginx-rtmps/⁠

⁠Details

⁠How to use

  • For the simplest case, just run a container with this image:
docker run -it -p 1935:1935 --name nginx-rtmps ido1990/nginx-rtmps
  • Facebook and Youtube:
docker run -it -p 1935:1935 -e FACEBOOK_KEY="<key>" -e YOUTUBE_KEY=<key> ido1990/nginx-rtmps
  • Cloudflare:
docker run -it -p 1935:1935 -e CLOUDFLARE_KEY="<key>" ido1990/nginx-rtmps
  • Twitch:
docker run -it -p 1935:1935 -e TWITCH_URL="rtmp://<url>" -e TWITCH_KEY="<key>" ido1990/nginx-rtmps
  • Telegram:
docker run -it -p 1935:1935 -e TELEGRAM_KEY="<key>" -e STREAM_TOKEN="mystreamexmaple" ido1990/nginx-rtmps
  • OBS
rtmp://localhost:1935/live
  • Instagram:
docker run -it -p 1935:1935 -e INSTAGRAM_KEY=<key> ido1990/nginx-rtmps
  • OBS
rtmp://localhost:1935/instagram

⁠How to test with OBS Studio

  • Run a container with the command above

  • Open OBS Studio⁠

  • Click the "Settings" button

  • Go to the "Stream" section

  • In "Stream Type" select "Custom Streaming Server"

  • In the "URL" enter the rtmp://<ip_of_host>/live replacing <ip_of_host> with the IP of the host in which the container is running. For example: rtmp://192.168.0.30/live

  • In the "Stream key" use a "key" that will be used later in the client URL to display that specific stream. For example: test

  • Click the "OK" button

  • In the section "Sources" click de "Add" button (+) and select a source (for example "Screen Capture") and configure it as you need

  • Click the "Start Streaming" button

⁠Debugging

If something is not working you can check the logs of the container with:

docker logs nginx-rtmp

⁠Extending

If you need to modify the configurations you can create a file nginx.conf and replace the one in this image using a Dockerfile that is based on the image, for example:

FROM ido1990/nginx-rtmps

COPY nginx.conf /etc/nginx/nginx.conf

The current nginx.conf contains:

worker_processes auto;
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
events {}
rtmp {
    server {
        listen 1935;
        listen [::]:1935 ipv6only=on;
        chunk_size 4096;

        application live {
            live on;
            record off;
	    #push rtmp://a.rtmp.youtube.com/live2/<key>;
	    #push rtmp://127.0.0.1:19350/rtmp/<key>;
	    #push rtmp://127.0.0.1:19352/live/<key>;
        }
        
        application instagram {
            live on;
            record off;
            #push rtmp://127.0.0.1:19351/rtmp/<key>;
        }

    }

}

Tag summary

Content type

Image

Digest

sha256:493474630…

Size

390.7 MB

Last updated

over 3 years ago

docker pull ido1990/nginx-rtmps