|
| 1 | +## Supported tags and respective `Dockerfile` links |
| 2 | + |
| 3 | +* [`latest` _(Dockerfile)_]() |
| 4 | + |
| 5 | +# nginx-rtmp |
| 6 | + |
| 7 | +[**Docker**](https://www.docker.com/) image with [**Nginx**](http://nginx.org/en/) using the [**nginx-rtmp-module**](https://github.com/arut/nginx-rtmp-module) module for live multimedia (video) streaming. |
| 8 | + |
| 9 | +## Description |
| 10 | + |
| 11 | +This [**Docker**](https://www.docker.com/) image can be used to create an RTMP server for multimedia / video streaming using [**Nginx**](http://nginx.org/en/) and [**nginx-rtmp-module**](https://github.com/arut/nginx-rtmp-module), built from the current latest sources (Nginx 1.11.3 and nginx-rtmp-module 1.1.9). |
| 12 | + |
| 13 | +This was inspired by other similar previous images from [dvdgiessen](https://hub.docker.com/r/dvdgiessen/nginx-rtmp-docker/), [jasonrivers](https://hub.docker.com/r/jasonrivers/nginx-rtmp/), [aevumdecessus](https://hub.docker.com/r/aevumdecessus/docker-nginx-rtmp/) and by an [OBS Studio post](https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/). |
| 14 | + |
| 15 | +The main purpose (and test case) to build it was to allow streaming from [**OBS Studio**](https://obsproject.com/) to different clients at the same time. |
| 16 | + |
| 17 | +**GitHub repo**: <https://github.com/tiangolo/nginx-rtmp-docker> |
| 18 | + |
| 19 | +**Docker Hub image**: <https://hub.docker.com/r/tiangolo/nginx-rtmp/> |
| 20 | + |
| 21 | +## Details |
| 22 | + |
| 23 | + |
| 24 | +## How to use |
| 25 | + |
| 26 | +* For the simplest case, just run a container with this image: |
| 27 | + |
| 28 | +```bash |
| 29 | +docker run -d -p 1935:1935 --name nginx-rtmp tiangolo/nginx-rtmp |
| 30 | +``` |
| 31 | + |
| 32 | +## How to test with OBS Studio and VLC |
| 33 | + |
| 34 | + |
| 35 | +* Run a container with the command above |
| 36 | + |
| 37 | + |
| 38 | +* Open [OBS Studio](https://obsproject.com/) |
| 39 | +* Click the "Settings" button |
| 40 | +* Go to the "Stream" section |
| 41 | +* In "Stream Type" select "Custom Streaming Server" |
| 42 | +* 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` |
| 43 | +* In the "Stream key" use a "key" that will be used later in the client URL to display that specific stream. For example: `test` |
| 44 | +* Click the "OK" button |
| 45 | +* In the section "Sources" click de "Add" button (`+`) and select a source (for example "Display Capture") and configure it as you need |
| 46 | +* Click the "Start Streaming" button |
| 47 | + |
| 48 | + |
| 49 | +* Open a [VLC](http://www.videolan.org/vlc/index.html) player (it also works in Raspberry Pi using `omxplayer`) |
| 50 | +* Click in the "Media" menu |
| 51 | +* Click in "Open Network Stream" |
| 52 | +* Enter the URL from above as `rtmp://<ip_of_host>/live/<key>` replacing `<ip_of_host>` with the IP of the host in which the container is running and `<key>` with the key you created in OBS Studio. For example: `rtmp://192.168.0.30/live/test` |
| 53 | +* Click "Play" |
| 54 | +* Now VLC should start playing whatever you are transmitting from OBS Studio |
| 55 | + |
| 56 | +## Debugging |
| 57 | + |
| 58 | +If something is not working you can check the logs of the container with: |
| 59 | + |
| 60 | +```bash |
| 61 | +docker logs nginx-rtmp |
| 62 | +``` |
| 63 | + |
| 64 | +## Extending |
| 65 | + |
| 66 | +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: |
| 67 | + |
| 68 | +```Dockerfile |
| 69 | +FROM tiangolo/nginx-rtmp |
| 70 | + |
| 71 | +COPY nginx.conf /etc/nginx/nginx.conf |
| 72 | +``` |
| 73 | + |
| 74 | +The current `nginx.conf` contains: |
| 75 | + |
| 76 | +```Nginx |
| 77 | +worker_processes auto; |
| 78 | +rtmp_auto_push on; |
| 79 | +events {} |
| 80 | +rtmp { |
| 81 | + server { |
| 82 | + listen 1935; |
| 83 | + listen [::]:1935 ipv6only=on; |
| 84 | +
|
| 85 | + application live { |
| 86 | + live on; |
| 87 | + record off; |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +You can start from it and modify it as you need. Here's the [documentation related to `nginx-rtmp-module`](https://github.com/arut/nginx-rtmp-module/wiki/Directives). |
| 94 | + |
| 95 | +## Technical details |
| 96 | + |
| 97 | +* This image is built from the same base official images that most of the other official images, as Python, Node, Postgres, Nginx itself, etc. Specifically, [buildpack-deps](https://hub.docker.com/_/buildpack-deps/) which is in turn based on [debian](https://hub.docker.com/_/debian/). So, if you have any other image locally you probably have the base image layers already downloaded. |
| 98 | + |
| 99 | +* It is built from the official sources of **Nginx** and **nginx-rtmp-module** without adding anything else. (Surprisingly, most of the available images that include **nginx-rtmp-module** are made from different sources, old versions or add several other components). |
| 100 | + |
| 101 | +* It has a simple default configuration that should allow you to send one or more streams to it and have several clients receiving multiple copies of those streams simultaneously. (It includes `rtmp_auto_push` and an automatic number of worker processes). |
| 102 | + |
| 103 | +## License |
| 104 | + |
| 105 | +This project is licensed under the terms of the Apache license. |
0 commit comments